Statistical Modelling

Author

Josie Athens

Published

February 15, 2024

2 Introduction

2.1 Initial data manipulation

Example

We will look at data from 500 singleton births in a London Hospital. We will estimate the effect of several potential predictors on the birth weights of babies.

R"""
data(births, package = "Epi")
""";
@rget births
births |> dropmissing!
births |> schema
┌─────────┬────────────┬─────────┐
│ names   │ scitypes   │ types   │
├─────────┼────────────┼─────────┤
│ id      │ Continuous │ Float64 │
│ bweight │ Continuous │ Float64 │
│ lowbw   │ Continuous │ Float64 │
│ gestwks │ Continuous │ Float64 │
│ preterm │ Continuous │ Float64 │
│ matage  │ Continuous │ Float64 │
│ hyp     │ Continuous │ Float64 │
│ sex     │ Continuous │ Float64 │
└─────────┴────────────┴─────────┘

In this tutorial, we have a first look at machine learning with MLJ. MLJ requires that all our variables are of scitype Continuous. For convenience, I will transform categorical variables in R and save it as a different data frame.

R"""
births2 = births %>%
  mutate(
    low = factor(lowbw, labels=c('No', 'Yes')),
    preterm = factor(preterm, labels=c('No', 'Yes')),
    hyp = factor(hyp, labels=c('No hypertension', 'Hypertension')),
    sex = factor(sex, labels=c('Male', 'Female'))
  ) %>%
  na.omit() %>%
  var_labels(
    bweight = "Birth weight (g)",
    low = "Birth weight < 2.5 kg?",
    gestwks = "Gestation period (weeks)",
    preterm = "Gestation period < 37 weeks?",
    matage = "Maternal age (years)",
    hyp = "Maternal hypertension",
    sex = "Sex"
  )
""";
@rget births2
DataFrames.rename!(
    births2,
    :gestwks => :Gestation,
    :matage => :Age,
    :hyp => :Hypertension,
    :sex => :Sex
);

2.2 Descriptive statistics

Let’s start by looking at the table of descriptive statistics.

R"""
births2 %>%
select(-c(id, lowbw)) %>%
tbl_summary() %>% 
cosm_sum(bold=TRUE) %>% theme_pubh() %>% 
set_caption("Descriptive statistics of singleton births in a London Hospital.") %>%
print_html()
""";
Descriptive statistics of singleton births in a London Hospital.

Variable

N = 490

Birth weight (g) 3,188 (2,860, 3,554)
Gestation period (weeks) 39.13 (37.94, 40.09)
Gestation period < 37 weeks? 63 (13%)
Maternal age (years) 34.0 (31.0, 37.0)
Maternal hypertension
No hypertension 419 (86%)
Hypertension 71 (14%)
Sex
Male 256 (52%)
Female 234 (48%)
Birth weight < 2.5 kg? 59 (12%)
Exercise

Construct QQ-Norm plots to check the distributions of birth weight and gestational period.

Code
let
    p1 = qq_plot(births.bweight, ylab = "Birth weight (g)")
    p2 = qq_plot(births.gestwks, ylab = "Gestational weeks")
        
    hstack(p1, p2)
end
Theoretical quantiles 20 30 40 50 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 20.0 20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.9 22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.2 26.3 26.4 26.5 26.6 26.7 26.8 26.9 27.0 27.1 27.2 27.3 27.4 27.5 27.6 27.7 27.8 27.9 28.0 28.1 28.2 28.3 28.4 28.5 28.6 28.7 28.8 28.9 29.0 29.1 29.2 29.3 29.4 29.5 29.6 29.7 29.8 29.9 30.0 30.1 30.2 30.3 30.4 30.5 30.6 30.7 30.8 30.9 31.0 31.1 31.2 31.3 31.4 31.5 31.6 31.7 31.8 31.9 32.0 32.1 32.2 32.3 32.4 32.5 32.6 32.7 32.8 32.9 33.0 33.1 33.2 33.3 33.4 33.5 33.6 33.7 33.8 33.9 34.0 34.1 34.2 34.3 34.4 34.5 34.6 34.7 34.8 34.9 35.0 35.1 35.2 35.3 35.4 35.5 35.6 35.7 35.8 35.9 36.0 36.1 36.2 36.3 36.4 36.5 36.6 36.7 36.8 36.9 37.0 37.1 37.2 37.3 37.4 37.5 37.6 37.7 37.8 37.9 38.0 38.1 38.2 38.3 38.4 38.5 38.6 38.7 38.8 38.9 39.0 39.1 39.2 39.3 39.4 39.5 39.6 39.7 39.8 39.9 40.0 40.1 40.2 40.3 40.4 40.5 40.6 40.7 40.8 40.9 41.0 41.1 41.2 41.3 41.4 41.5 41.6 41.7 41.8 41.9 42.0 42.1 42.2 42.3 42.4 42.5 42.6 42.7 42.8 42.9 43.0 43.1 43.2 43.3 43.4 43.5 43.6 43.7 43.8 43.9 44.0 44.1 44.2 44.3 44.4 44.5 44.6 44.7 44.8 44.9 45.0 45.1 45.2 45.3 45.4 45.5 45.6 45.7 45.8 45.9 46.0 46.1 46.2 46.3 46.4 46.5 46.6 46.7 46.8 46.9 47.0 47.1 47.2 47.3 47.4 47.5 47.6 47.7 47.8 47.9 48.0 48.1 48.2 48.3 48.4 48.5 48.6 48.7 48.8 48.9 49.0 49.1 49.2 49.3 49.4 49.5 49.6 49.7 49.8 49.9 50.0 0 50 45.8519884447907443.01030635055231 45.05886153454524442.58171421362428 44.660503830173542.25051019629654 44.38577341969073642.170428657531744 44.17338923971071642.10073505713013 43.9989772673869942.055112574051805 43.8502616457643442.040264320373524 43.7201569622785142.01061242940476 43.6041886207148941.97552083463087 43.4993434222040541.921551058243736 43.4034919465967841.86085777282713 43.3150715863245541.816173985539635 43.2329004744924241.75204086303711 43.1560622489603541.69582619180488 43.0838315085589441.670591926574716 43.01562381540525641.52885756200672 42.9509611199812441.347358353283916 42.8894472175618341.30071544647214 42.8307499260869741.276132369527986 42.7745878855218341.25079578477509 42.7207206076606641.23083820343017 42.6689408583730441.20175590515136 42.6190687437332541.17545851882623 42.570947060973641.15191784683537 42.5244376020168141.121000862121576 42.4794181838963241.1100006103516 42.43578024051305441.105540474093715 42.39342685264719541.07780493522175 42.35227112358387641.0499992370605 42.3122348298292441.045602016059675 42.2732472926656141.0400009155273 42.2352444284065641.035642841884055 42.1981679443248341.02566277250955 42.161964654150341.0200004577637 42.1265858923461841.0200004577637 42.0919870104800341.015724034212084 42.0581269422116741.00574393369713 42.0249678259380840.995766016901754 41.9924746761302640.9900016784668 41.9606150959854240.98161373138427 41.9293590252931940.9700012207031 41.8986785184424540.96169490814209 41.868547548330840.945867227048325 41.83894183261908540.935887072037694 41.8098386793325140.9300003051758 41.7812168492700640.92592800685338 41.7530564330649840.9199981689453 41.7253387410563740.91193829750527 41.698046204396540.89599046512524 41.67116228604060540.87005071445385 41.64467140045274440.832061195373534 41.618558841019340.8199996948242 41.5928107142955740.8199996948242 41.56741388032471540.81218318939206 41.54235589836590540.7999992370605 41.5176249774512440.7999992370605 41.49320993126307440.79615294398089 41.4691001368845740.786173567479956 41.44528549702969440.76858087656451 41.4217564054049140.746214921133856 41.398503714894740.7400016784668 41.3755187082980940.7400016784668 41.35279307137345540.73627639303401 41.3303188679757840.7299995422363 41.30808851709337440.71894897149534 41.28609477161210640.68901001677224 41.2643306986525640.6699981689453 41.2427896613419540.666376327981745 41.2214653018964440.652795600891096 41.2003515259017340.6399993896484 41.1794424876913640.63643876289831 41.158732576731340.62645949538872 41.1382164049287740.61647911461036 41.1178887947903840.6030004501343 41.09774476836232540.5865211447891 41.07777953689084440.57654190841986 41.057988491147440.56656149650105 41.0383671923675340.556582275702006 41.0189113637571640.5499992370605 40.99961688252396640.533111739645165 40.9804797723951940.5 40.9614961965865140.49332637786864 40.9426624511895940.4799995422363 40.9239749589485740.4799995422363 40.9054302633982840.4799995422363 40.8870250233390140.47348918914794 40.8687560076249740.45676493352778 40.85062009024501640.4500007629395 40.83261424567620440.4500007629395 40.8147355444921140.44682661562554 40.79698114920919540.43369235992432 40.77934831035586440.41686604168949 40.7618343627499840.400663492630926 40.74443672197154640.376908570892944 40.7271528810184640.36692801884246 40.709980407133940.3600006103516 40.6929169387948440.3600006103516 40.6759601828519440.35698976322099 40.6591079118117140.3499984741211 40.6423579612524740.3499984741211 40.6257082273662240.3470499895057 40.6091566646191540.33707207271032 40.5927012835238340.32127658688292 40.57634014851685640.29711196665856 40.56007137593578440.28426609039305 40.5438931320899740.26430644989016 40.5278036314199740.244346809387196 40.5118011347407540.22438716888427 40.49588394756399640.2099990844727 40.4800504184953640.207234242497705 40.4642989377025840.197255278606846 40.4486279354507940.189998626709 40.43303588070132540.18729499894747 40.4175212797709440.1800003051758 40.40208267504810640.17201083436306 40.386718643763640.1500015258789 40.3714277968125940.14737851668376 40.3562087776256140.137397785575985 40.34106026108601440.12741888396592 40.3259809524915840.11743813728803 40.3109695865581240.10745925124814 40.2960249264630640.097478488999975 40.28114576292740.0900001525879 40.26633091333149440.08752097694242 40.2515792208713740.077542122042914 40.23688955373981540.0699996948242 40.2222608043448540.06758173339219 40.2076918885556340.05760290184797 40.19318174497729540.04762208510414 40.1787293342529440.0400009155273 40.1643336383915840.03766368165306 40.14999366012093440.0299987792969 40.1357084222638240.0299987792969 40.12147696713723440.0299987792969 40.1072983559730940.025488471984886 40.0931716683595640.007764002741595 40.0790960017022739.99557132720947 40.06507047070445539.97780603292034 40.0510942068651739.967827287012206 40.0371663579949439.9599990844727 40.0232860877479839.95786678937021 40.0094525751703239.94788806681734 39.9956650142633339.939998626709 39.981922613561739.93792754581998 39.9682245957255839.9279488466224 39.95457019714612639.9199981689453 39.9409586675639939.91798830226975 39.9273892697001739.90801038547438 39.91386127889878639.9000015258789 39.9003739827812739.9000015258789 39.8869266809115239.89614429473876 39.8735186844716339.8800010681152 39.8601493159476639.87622547149656 39.8468179088252839.8600006103516 39.83352380729465439.8600006103516 39.82026636596436539.85817368955031 39.8070449495840139.8499984741211 39.7938589327751239.8499984741211 39.78070769977005539.8499984741211 39.7675906441586539.84825386903725 39.7545071686423139.838275952241865 39.7414566847951639.826593589782725 39.72843861283216439.810001373291 39.71545238138385539.80833775267307 39.7024974272774339.7999992370605 39.68957319532401639.7999992370605 39.67667913811186539.795193310173154 39.6638147158052639.7700004577637 39.6509793959489439.76843889976037 39.63817265327785639.7599983215332 39.6253939695320139.7599983215332 39.6126428332762639.7599983215332 39.5999187397249239.758518978041046 39.587221190570939.75 39.5745496938193439.748561465983485 39.56190376362551639.7400016784668 39.54928292013682539.73580743828599 39.5366866893388739.7099990844727 39.52411460290528639.708642169407476 39.5115661980513539.7000007629395 39.4990410173911539.7000007629395 39.4865386087982639.69870456773412 39.4740585252697439.687447547912605 39.4616003247933339.66874327756919 39.4491635702178639.65876536077382 39.4367478291265839.6500015258789 39.4243526737134939.648807393288116 39.411977680662439.6399993896484 39.399622431028839.63884652196141 39.3872865101242639.62886817309319 39.3749695074034639.6199989318848 39.36267101635361639.61890727841128 39.3503906343862739.60892895289833 39.33812796273140639.5999984741211 39.3258826063337539.59793759560099 39.313654173751239.5800018310547 39.30144227705534439.57901182369311 39.2892465317339239.5699996948242 39.27706655659526539.5699996948242 39.2649019736745739.56907127925325 39.2527524081419239.560001373291 39.2406174882121439.55911342854401 39.2284968450561939.549132035703025 39.2163901127143139.5400009155273 39.20429692801056439.53834781646725 39.19221693046904439.5200004577637 39.180149762231439.5200004577637 39.1680950679758339.519234988154224 39.1560524948373439.50925354860267 39.1440216923294239.499275631807286 39.1320023122668339.4900016784668 39.11999400868969439.4900016784668 39.10799643778868539.4900016784668 39.0960092578313139.488715934753415 39.08403212908936639.469378638754065 39.0720647137672539.45939714470692 39.0601066759314239.4500007629395 39.048157681440739.449439418559216 39.0362173978775339.439457901156686 39.0242854944800539.4300003051758 39.0123616420750539.4300003051758 39.0004455130116939.4300003051758 38.98853678109639.42954102341012 38.9766351215260639.41912076521891 38.9647402108278939.39916477203368 38.9528517267920439.3800010681152 38.940969348410739.378868317117465 38.92909275581547539.3499984741211 38.9172216302157239.3499984741211 38.9053556538373439.3499984741211 38.8934945098621239.349406736724234 38.8816378823675539.328348731994645 38.8697854562669839.268980026245146 38.8579369172503339.22976488775134 38.84609195172501539.2200012207031 38.8342502467573439.219807301735365 38.82241149001412639.2098256442012 38.81057536970466539.2000007629395 38.7987415745229539.19986808154052 38.7869097935900739.18988640065098 38.7750797163968939.1800003051758 38.7632510327468339.17992886134558 38.7514234326988839.16984511394888 38.73959660651062439.139968782541665 38.7277702445814939.12999086185374 38.7159440373959439.12000913814626 38.7041176754668139.1199989318848 38.6922908492785639.11005162219616 38.68046324923060639.100069917951316 38.6686345655805539.0900919739081 38.65680448838736539.060338094283104 38.64497270745448539.05013191845947 38.6331389122727739.04015395106097 38.6213027919633139.0400009155273 38.6094640352200939.0400009155273 38.5976223302524239.0400009155273 38.5857773647271139.02046985626223 38.5739288257104539.0200004577637 38.56207639960988639.01027389059262 38.5502197721153139.0099983215332 38.53835862814009538.990634225339306 38.5264926517617138.9900016784668 38.5146215261619638.9900016784668 38.5027449335667438.9900016784668 38.49086255518539438.98039758643323 38.4789740711495438.97041951782847 38.4670791604513838.9700012207031 38.4551775008814338.960458366238385 38.44326876896574438.950480274278334 38.43135263990238638.94049873352052 38.4194287874973938.93052062599029 38.40749688409990638.9300003051758 38.39555660053673638.920559513325585 38.3836076060460138.9199981689453 38.3716495682101938.91060178717788 38.3596821528880738.9099998474121 38.3477050241461238.90064427512032 38.3357178441887538.9000015258789 38.3237202732877438.9000015258789 38.3117119697106138.89070362168912 38.2996925896480238.8899993896484 38.28766178714009538.88074584104573 38.2756192140016138.87076440149427 38.2635645197460338.86078619275778 38.2514973515083938.85080476877641 38.2394173539668738.831654614818355 38.2273241692631338.80254027308246 38.2152174369212438.78173351287844 38.203096793765338.77088806385899 38.1909618738355138.75181636810303 38.1788123083028738.75 38.1666477253821738.75 38.1544677502435138.740970903513386 38.1422720049220938.7219808578491 38.1300601082262338.7200012207031 38.11783167564368638.6930907307839 38.1055863192460338.689998626709 38.0933236475911638.689998626709 38.0810432656238238.681091958649326 38.0687447745739738.6800003051758 38.0564277718531738.67113106396732 38.0440918509486438.66115271509909 38.0317366013150338.642346382141085 38.0193616082639438.63119474527784 38.00696645285085438.60364164624896 37.9945507117595738.5999984741211 37.982113957184138.58251161380691 37.96965575670769538.5800018310547 37.9571756731791738.5800018310547 37.94467326458628538.562634086608874 37.9321480839260938.55133625731172 37.9195996790721438.5499992370605 37.9070275926385638.524132942666824 37.8944313618406138.51139657935318 37.8818105183519238.5099983215332 37.8691645881580938.5099983215332 37.85649309140653438.50145893875433 37.84379554225251538.482958793640115 37.83107144870117438.4799995422363 37.8183203124454238.4799995422363 37.8055416286995838.454623023831154 37.792734886028538.4500007629395 37.77989956617217638.44158059723525 37.7670351438655738.439998626709 37.7541410866534238.439998626709 37.74121685470000638.414928218296595 37.7282619005935838.37665214538577 37.7152756691452738.36168400122199 37.70225759718227538.3600006103516 37.6892071133351238.3600006103516 37.6761236378187838.34349002838136 37.6630065822073838.33176684087638 37.6498553492023138.29714393615719 37.63666933239342438.273612785339374 37.6234479160130738.2700004577637 37.6101904746827838.2700004577637 37.59689637315215538.261866067380325 37.58356496602977638.2599983215332 37.5701955975058138.2599983215332 37.5567876010659138.2599983215332 37.5433402991961738.25194865246208 37.5298530030786538.233938407897924 37.51632501227726438.2299995422363 37.50275561441344538.2299995422363 37.4891440848313138.214060401916534 37.47548968625185538.18615311603159 37.46179166841573538.1800003051758 37.44804926771410438.164183616638184 37.4342617068071138.152113416243566 37.4204281942294638.1500015258789 37.40654792398249438.14215291081639 37.3926200751122638.10086733370411 37.3786438112729838.0900001525879 37.3646182802751738.0900001525879 37.35054261361787638.074469184875475 37.3364159260043438.06225609682043 37.32223731484019438.05227523336601 37.3080058597136238.04229644853237 37.293720621856538.03231560064823 37.2793806435858538.0299987792969 37.2649849477244938.02235720498224 37.2505325370001437.9818887944124 37.23602239342180637.9700012207031 37.22145347763258637.96241796843862 37.2068247282376237.9599990844727 37.19213506110606537.9599990844727 37.1773833686459437.944957923889184 37.1625685190504437.939998626709 37.1476893555143737.91756076423489 37.1327446954193137.90254191573785 37.1177333294858637.892561161274784 37.1026540208914237.8899993896484 37.08750550435182437.882602672187616 37.07228648516484537.87262194107991 37.05699563821383437.86264302389966 37.0416316069293337.8600006103516 37.026193002206537.852682720885 37.0106784012761137.842703780349424 36.99508634652665537.83272586355405 36.97941534427485537.822745179156854 36.96366386348207637.798296496332874 36.9478303344134437.7900009155273 36.93191314723668537.78280550119829 36.91591065055746437.75130698145653 36.89982114988746537.7400016784668 36.8836429060416537.7400016784668 36.8673741334605837.7400016784668 36.85101299845360537.71163368225101 36.83455761735828637.68585758209232 36.8180060546112237.67294777850715 36.8013563207249637.65593930458535 36.78460637016572637.6500015258789 36.767754099125537.63602161407468 36.750797343182637.6230301915383 36.7337338748435437.59915284137338 36.7165614009589737.5900001525879 36.6992775600058937.58309314883486 36.68187991922745537.57311260456941 36.6643659716215737.556264686584434 36.6467331327682437.543153447520936 36.62897873748532637.53317292661083 36.6111000363012337.502776262711514 36.5930941917324237.47642993927 36.5749582743524737.46323446935539 36.5566892586384337.4599990844727 36.5382840185791637.446549797058125 36.51973932302886537.43329567033419 36.50105183078784437.4233152039197 36.48221808539092637.40667387514697 36.4632345095822437.39335724966864 36.4440973994534737.37013285111409 36.4248029182202737.34019529381579 36.40534708960990437.3300018310547 36.3857257908300437.3300018310547 36.3659347450865937.2907560348511 36.3459695136151137.26347865669096 36.3258254871870537.23400020599363 36.30549787704866637.2200012207031 36.2849817052461337.187703331149336 36.26427179428607437.1699981689453 36.24336275607570537.14432656035129 36.22224898008137.11720485687257 36.2009246206354837.10362169693929 36.1793835833248837.0999984741211 36.1576195103653337.08732713193311 36.1356257648840637.061051213011424 36.1133954140016637.04370437544215 36.0909212106039837.00862384329035 36.06819557367935436.95872425935707 36.04521056708273436.939998626709 36.0219578765725236.92756977081299 35.9984287849477436.87664121511031 35.9746141450928736.83147881955516 35.9505043507143636.64771473164458 35.92608930452619436.533866952390085 35.9013583836115336.49943802113435 35.8763004016527236.46172477566468 35.8509035676818736.44392803737098 35.82515544095813536.42184630413445 35.7990428815246936.403970247385445 35.7725519959368336.38196935459061 35.7456680775809436.3699989318848 35.71837554092106636.35805988311769 35.6906578489124636.308355798526705 35.66249743270737636.27407120295936 35.6338756026449336.2522766891791 35.6047724493583536.234112665604556 35.5751667336466336.188928292722096 35.5450357635349836.11907145441795 35.5143552566842536.02008240758155 35.4830991859920235.95838871002199 35.4512396058471835.822714342389794 35.4187464560393635.71270432764172 35.3855873397657635.68851070404056 35.351727271497435.64565258026126 35.3171283896312635.55155056155459 35.2817496278271335.44884685204953 35.24554633765260535.33071447878469 35.20846985357087535.19664271218436 35.1704669893118334.98819300982417 35.131479452148234.77476526377157 35.0914431583935634.683254417108046 35.0502874293302434.6699981689453 35.0079340414643834.65337639633488 34.96429609808111434.61239777000581 34.9192766799606234.4525001525879 34.8727672210038334.25780543891752 34.82464553824418434.162703124844285 34.77477342360439434.09649026442545 34.72299367431677634.038327407836924 34.669126396455633.831070650840296 34.6129643558904633.43338666254158 34.55426706441560533.00500052315846 34.492753161996232.80466349854758 34.4280904665721832.714938093691416 34.359882773418532.58174396437042 34.2876520330170832.49834700603874 34.2108138074850232.43846988677977 34.12864269565288632.04357087660811 34.0402223353806531.532714285169348 33.94437085977338631.328449858451357 33.8395256612625431.06236798617301 33.7235573196989330.77785685597635 33.59345263621309430.679203440218586 33.4447370145904430.583540863893496 33.2703250422667229.25722518064537 33.057940862286728.014643192291256 32.78321045180394627.656632501251885 32.3848527474321827.13883708058576 31.59172583718668625.817694525816016 h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? 0 10 20 30 40 50 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.2 26.3 26.4 26.5 26.6 26.7 26.8 26.9 27.0 27.1 27.2 27.3 27.4 27.5 27.6 27.7 27.8 27.9 28.0 28.1 28.2 28.3 28.4 28.5 28.6 28.7 28.8 28.9 29.0 29.1 29.2 29.3 29.4 29.5 29.6 29.7 29.8 29.9 30.0 30.1 30.2 30.3 30.4 30.5 30.6 30.7 30.8 30.9 31.0 31.1 31.2 31.3 31.4 31.5 31.6 31.7 31.8 31.9 32.0 32.1 32.2 32.3 32.4 32.5 32.6 32.7 32.8 32.9 33.0 33.1 33.2 33.3 33.4 33.5 33.6 33.7 33.8 33.9 34.0 34.1 34.2 34.3 34.4 34.5 34.6 34.7 34.8 34.9 35.0 35.1 35.2 35.3 35.4 35.5 35.6 35.7 35.8 35.9 36.0 36.1 36.2 36.3 36.4 36.5 36.6 36.7 36.8 36.9 37.0 37.1 37.2 37.3 37.4 37.5 37.6 37.7 37.8 37.9 38.0 38.1 38.2 38.3 38.4 38.5 38.6 38.7 38.8 38.9 39.0 39.1 39.2 39.3 39.4 39.5 39.6 39.7 39.8 39.9 40.0 40.1 40.2 40.3 40.4 40.5 40.6 40.7 40.8 40.9 41.0 41.1 41.2 41.3 41.4 41.5 41.6 41.7 41.8 41.9 42.0 42.1 42.2 42.3 42.4 42.5 42.6 42.7 42.8 42.9 43.0 43.1 20 30 40 50 Gestational weeks Theoretical quantiles 0 1000 2000 3000 4000 5000 6000 0 250 500 750 1000 1250 1500 1750 2000 2250 2500 2750 3000 3250 3500 3750 4000 4250 4500 4750 5000 5250 5500 5750 6000 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360 1380 1400 1420 1440 1460 1480 1500 1520 1540 1560 1580 1600 1620 1640 1660 1680 1700 1720 1740 1760 1780 1800 1820 1840 1860 1880 1900 1920 1940 1960 1980 2000 2020 2040 2060 2080 2100 2120 2140 2160 2180 2200 2220 2240 2260 2280 2300 2320 2340 2360 2380 2400 2420 2440 2460 2480 2500 2520 2540 2560 2580 2600 2620 2640 2660 2680 2700 2720 2740 2760 2780 2800 2820 2840 2860 2880 2900 2920 2940 2960 2980 3000 3020 3040 3060 3080 3100 3120 3140 3160 3180 3200 3220 3240 3260 3280 3300 3320 3340 3360 3380 3400 3420 3440 3460 3480 3500 3520 3540 3560 3580 3600 3620 3640 3660 3680 3700 3720 3740 3760 3780 3800 3820 3840 3860 3880 3900 3920 3940 3960 3980 4000 4020 4040 4060 4080 4100 4120 4140 4160 4180 4200 4220 4240 4260 4280 4300 4320 4340 4360 4380 4400 4420 4440 4460 4480 4500 4520 4540 4560 4580 4600 4620 4640 4660 4680 4700 4720 4740 4760 4780 4800 4820 4840 4860 4880 4900 4920 4940 4960 4980 5000 5020 5040 5060 5080 5100 5120 5140 5160 5180 5200 5220 5240 5260 5280 5300 5320 5340 5360 5380 5400 5420 5440 5460 5480 5500 5520 5540 5560 5580 5600 5620 5640 5660 5680 5700 5720 5740 5760 5780 5800 5820 5840 5860 5880 5900 5920 5940 5960 5980 6000 0 10000 5109.9364374454274534.53775510204 4890.5869007659864514.012244897959 4780.4159095187194506.556122448979 4704.435650278124468.964285714286 4645.6980499333784429.619387755102 4597.4621562493344382.431632653059 4556.3329217238934329.778571428571 4520.3507835896474311.7295918367345 4488.2782342121594302.069387755102 4459.281934352284293.752040816326 4432.7729652416664257.807142857141 4408.3191674847094225.04693877551 4385.5936804586364214.984693877551 4364.3430723251774201.220408163265 4344.3667239799174189.943877551021 4325.5030015441194180.594897959184 4307.6196942215714161.279591836734 4290.607226455394137.285714285715 4274.3737289872974132.075510204082 4258.8413880494234126.858163265306 4243.94369350849054108.255102040817 4229.6233320771774082.421428571428 4215.8305517564624070.091836734694 4202.5218760814734063.5755102040816 4189.6590818153884049.8 4177.2083776736634038.3122448979593 4165.1397382931134031.4326530612243 4153.4263594061124024.780612244898 4142.044208598814021.1163265306122 4130.9716521491454009.005102040817 4120.18914294079153990.622448979592 4109.67895779887753982.8214285714284 4099.4249751134173978.2653061224487 4089.41248553139673969.0938775510203 4079.6280299672483954.844897959184 4070.059260317743945.8622448979595 4060.6948191537133942.5744897959185 4051.52423535765963942.0 4042.5378332276443937.785714285714 4033.72665300756133926.5479591836734 4025.0823811562383915.661224489796 4016.59728895237463900.617346938776 4008.26417826313263884.34693877551 4000.07633349259143880.766326530612 3992.02747888072963867.542857142857 3984.11174045095783842.4500000000003 3976.32361200960583827.569387755102 3968.65792468848083819.566326530612 3961.10981959481343810.5938775510203 3953.67472319432863805.80306122449 3946.3483251048643804.0 3939.1265580216283801.630612244898 3932.00557953223733792.4999999999995 3924.9817556111623783.6091836734695 3918.05164561012133779.501020408163 3911.2119885839743773.6132653061222 3904.4596908114473773.0 3897.79181438707433771.8520408163267 3891.20556677540573770.0 3884.69829123133563769.2428571428572 3878.26745800139723767.623469387755 3871.91065623056743763.2551020408164 3865.6255865074643755.8826530612246 3859.4100539882173753.6295918367346 3853.2619620456973752.263265306123 3847.17930639646653748.069387755102 3841.1601696627783741.5428571428574 3835.2027163313653739.0 3829.30518807461753737.1989795918366 3823.46589940320063733.6418367346937 3817.68323362221243731.9316326530616 3811.95563906568173728.9377551020407 3806.28162558664143727.0 3800.6597612821323725.6 3795.08866943444173721.2602040816323 3789.5670256515933716.962244897959 3784.09355519163463711.217346938776 3778.66703045666963701.265306122449 3773.2862686438113695.6602040816324 3767.95012954135563695.0 3762.6575134594833694.664285714286 3757.4073592857153690.329591836735 3752.19864265614753681.341836734694 3747.03037423426443677.340816326531 3741.90159808977663675.0173469387755 3736.81139017056153670.0704081632653 3731.7588568613293663.35306122449 3726.7431336231423658.785714285714 3721.76338370838043650.4030612244896 3716.81879694615873646.6826530612248 3711.90858859359333642.84693877551 3707.03199824864673633.49387755102 3702.18828882061833627.066326530612 3697.37674555463173623.763265306123 3692.596675106733621.0 3687.84740466645143617.948979591836 3683.1282811239663609.4846938775513 3678.4386702790763605.698979591837 3673.7779560895583604.4020408163265 3669.1455399565133602.4061224489797 3664.54084004454763598.6408163265305 3659.9632906347473592.707142857143 3655.41234150855553592.0 3650.8874573607983591.711224489796 3646.38811724019023590.713265306122 3641.9138140157933588.576530612245 3637.46405386798143584.1520408163265 3633.03835580256873581.7193877551017 3628.6362511868263579.607142857143 3624.25728330622273576.0 3619.9010069407653575.7255102040817 3615.56698795990633574.455102040816 3611.2548029350463572.459183673469 3606.96403876870043571.0 3602.69429233949133569.934693877551 3598.44517016213153566.735714285714 3594.2162880616593565.737755102041 3590.00727086118743564.2193877551017 3585.81775208251753561.7418367346936 3581.64737365895373560.487755102041 3577.495785659743558.7459183673473 3573.3626460255443556.991836734694 3569.2476203144593553.5 3565.1503814580153551.7520408163264 3561.0706095267313550.7540816326527 3557.00799150474953549.0244897959183 3552.9622210731393545.7581632653064 3548.9329984014523545.0 3544.92002994716683544.2867346938774 3540.92302826264773542.0 3536.94171180928243538.2612244897955 3532.97580477848123524.3785714285714 3529.0250369192183518.770408163265 3525.08914337183753517.544897959184 3521.1678645078413514.421428571429 3517.2609457753963508.1061224489795 3513.3681375503233504.557142857143 3509.48919499231263503.0 3505.62387790616463502.782653061224 3501.77195060782063501.784693877551 3497.93318179500153500.1469387755105 3494.10734442224343494.6765306122447 3490.2942155801623486.0 3486.493576378763482.892857142857 3482.70521183461643470.1795918367347 3478.92891076183466.5938775510203 3475.1644656663543464.597959183673 3471.4116726442053463.0 3467.67033128236843462.6061224489795 3463.94024456330863460.2204081632653 3460.22121877233583456.614285714286 3456.5130634079173454.236734693877 3452.815591094793451.0 3449.1286174997653450.8132653061225 3445.4519612501243449.815306122449 3441.78544385449873448.8173469387757 3438.12888962614943447.638775510204 3434.48212560854433444.035714285714 3430.84498150315453434.4704081632653 3427.2172895993863431.6510204081633 3423.59888470655733429.655102040816 3419.98960408786073427.488775510204 3416.38928739622453424.6632653061224 3412.7977766120093422.334693877551 3409.21491598246853417.3571428571427 3405.6405519629183409.0 3402.07453315953533408.3591836734695 3398.5167102737513404.841836734694 3394.96693604815573403.0632653061225 3391.4250652138843397.0755102040816 3387.89095443940873392.0 3384.3644622807093391.1000000000004 3380.84544913275163386.0 3377.33377718224763385.854081632653 3373.82931036163653385.0 3370.33191430425363384.7163265306126 3366.84145630064043382.4408163265307 3363.35780525596333378.5867346938776 3359.8808316484893376.0 3356.41040748913375.8663265306122 3352.9464062817893374.341836734694 3349.48870298512843369.6112244897963 3346.03717397465153366.7448979591836 3342.5916970061373364.372448979592 3339.1521511797563359.259183673469 3335.71841690504743353.635714285714 3332.29037586670943350.880612244898 3328.8679109911613349.8826530612246 3325.45090641385923349.0 3322.03924744734243348.0938775510203 3318.6328205499753341.0 3315.231513295373340.6724489795915 3311.83521434246953337.892857142857 3308.44381340625163337.0 3305.0572012290543336.587755102041 3301.67526955248653332.898979591837 3298.29791108991053331.9010204081633 3294.9250194994763330.2244897959185 3291.55648935768073322.9051020408165 3288.1922161334523321.442857142857 3284.83209616271823315.545918367347 3281.4760266234613310.5561224489793 3278.1239055112293306.0 3274.7756316150973305.9153061224492 3271.43110449405373304.834693877551 3268.09022445380833302.4357142857143 3264.75289252399123296.0 3261.41901043574533295.8469387755104 3258.0884805996843293.8510204081635 3254.7612060842123291.927551020408 3251.43709059418733290.9295918367347 3248.11603844991623289.8632653061222 3244.7979545664663287.8673469387754 3241.48274443328863285.807142857143 3238.17031409413453282.9377551020407 3234.86057012725223281.819387755102 3231.55341962586233278.418367346939 3228.24877017888733268.887755102041 3224.94652985193623266.6755102040815 3221.64660716852683261.0 3218.3489110915383260.95 3215.053351004883259.9520408163266 3211.75983669537573258.908163265306 3208.46827833484083256.868367346939 3205.17858646235353253.832653061224 3201.8906719667053249.9602040816326 3198.60444606902273249.0 3195.31982030555453248.8214285714284 3192.03670651060933243.764285714286 3188.7550167996383236.9051020408165 3185.4746635524553233.9704081632653 3182.19555939658683232.807142857143 3178.917617190743225.8979591836733 3175.6407500083793221.8591836734695 3172.36487112140873215.807142857143 3169.08989398395353206.864285714286 3165.8157322162223200.0 3162.542299588453199.969387755102 3159.26951000492043197.986734693877 3155.9972774880383196.955102040816 3152.72551616247163192.990816326531 3149.45414023933653191.9857142857145 3146.18306400042053189.9948979591836 3142.91220178244573188.9969387755104 3139.64146796135263187.998979591837 3136.37077693660653187.001020408163 3133.10004311551353184.009183673469 3129.82918089753873184.0 3126.55810465862263184.0 3123.28672873548753184.0 3120.0149674099213183.011224489796 3116.7427348930393180.0397959183674 3113.46994530950863179.015306122449 3110.1965126817373178.0173469387755 3106.92235091400563178.0 3103.64737377655053172.1285714285714 3100.371494889583164.1877551020407 3097.0946277072193163.025510204082 3093.81668550137243160.0826530612244 3090.53758134550433156.1183673469386 3087.25722809832133154.0632653061225 3083.975538387353152.0673469387757 3080.69242459240473149.1071428571427 3077.40779882893643146.1132653061222 3074.12157293125443141.198979591837 3070.83365843560573140.041836734694 3067.5439665631183138.087755102041 3064.25240820258343138.0 3060.9588938930793134.1918367346934 3057.6633338064213134.0 3054.36563772943243126.416326530612 3051.0657150460233122.216326530612 3047.7634747190723122.0 3044.4588252720973120.1163265306122 3041.1516747707073117.180612244898 3037.84193080382473117.0 3034.52950046467053109.514285714286 3031.2142903314933105.265306122449 3027.8962064480433102.2051020408167 3024.5751543037723102.0 3021.2510388137473099.2173469387753 3017.92376429827533096.223469387755 3014.5932344622143096.0 3011.2593523739683095.078571428571 3007.9220204441513093.161224489796 3004.58114040390553092.0826530612244 3001.2366132828623092.0 2997.888339386733090.173469387755 2994.5362182744983087.266326530612 2991.1801487352413082.454081632653 2987.82002876450723082.0 2984.45575554027853079.284693877551 2981.08722539848353079.0 2977.7143338080483078.0989795918367 2974.33697534547263075.3030612244897 2970.9550436689053065.1336734693878 2967.56843149170753064.0 2964.17703055548963062.2142857142853 2960.7807316025893061.1091836734695 2957.37942434798423054.7785714285715 2953.97299745061673053.1132653061227 2950.56133848413051.230612244898 2947.1443339067983045.704081632653 2943.72186903124983042.3581632653063 2940.29382799291173041.1214285714286 2936.86009371820363041.0 2933.42054789182163040.1255102040814 2929.97507092330763039.127551020408 2926.52354191283083035.518367346939 2923.065838616173028.0530612244897 2919.60183740885943024.4010204081633 2916.13141324946953023.135714285714 2912.6544396419963010.928571428571 2909.17078859731873007.2795918367347 2905.6803305937063007.0 2902.18293453632263007.0 2898.67846771571163005.291836734694 2895.16679576520763004.1479591836737 2891.647782617253003.15 2888.12129045855043001.304081632653 2884.5871796840753001.0 2881.04530884980342995.9367346938775 2877.4955346242082992.474489795918 2873.9377117384242991.160204081633 2870.3716929350412990.162244897959 2866.797328915492989.164285714286 2863.21446828595032983.1642857142856 2859.62295750173462978.673469387755 2856.02264081009842974.6816326530616 2852.4133601914022974.0 2848.79495529857332969.872448979592 2845.16726339480462969.0 2841.53011928941532968.1785714285716 2837.88335527180972968.0 2834.22680104346052963.9132653061224 2830.5602836478352961.369387755102 2826.8836273981942959.373469387755 2823.19665380316972954.132653061224 2819.4991814900422951.381632653061 2815.79102612562342950.192857142857 2812.07200033465052949.194897959184 2808.34191361559122944.984693877551 2804.60057225375432944.0 2800.84777923160532943.2010204081635 2797.0833341361592939.015306122449 2793.30703306334272935.6153061224486 2789.51866851919932930.2428571428572 2785.7180293177972926.627551020408 2781.90490047571572924.4224489795915 2778.07906310295772922.4265306122447 2774.24029429013852921.215306122449 2770.38836699179462918.652040816327 2766.52304990564652914.8775510204077 2762.64410734763622913.2214285714285 2758.7512991225632911.44693877551 2754.84438039011872906.35306122449 2750.92310152612162896.5030612244896 2746.9872079787412894.0 2743.0364401194782893.231632653061 2739.07053308867672890.7010204081635 2735.08921663531152887.7071428571426 2731.09221495079242887.0 2727.0792464965072885.479591836735 2723.050023824822880.4510204081635 2719.00425339320962878.2438775510204 2714.9416353712282868.9510204081635 2710.8618634399442863.743877551021 2706.76462458350032860.0 2702.6495988724152856.0081632653064 2698.51645923821932852.762244897959 2694.36487123900542849.7683673469387 2690.19449281544172845.290816326531 2686.00497403677172843.2602040816328 2681.79595683630032842.262244897959 2677.5670747358272838.3214285714284 2673.3179525584682832.5979591836735 2669.04820612925872830.2683673469387 2664.7574419629132811.030612244898 2660.4452569380532802.544897959184 2656.1112379571942801.2744897959183 2651.75496159173642798.1061224489795 2647.3759937111332797.0 2642.97388909539042796.280612244898 2638.54819102997772787.391836734694 2634.0984308821662773.2704081632655 2629.6241276577692768.2867346938774 2625.1247875371612765.155102040816 2620.59990338940362762.581632653061 2616.0489542632122754.2214285714285 2611.47140485341152746.0642857142857 2606.8667049414462741.1877551020407 2602.23428880840132737.195918367347 2597.5735746188832733.204081632653 2592.8839637739932729.9091836734697 2588.16484023150772725.5255102040815 2583.41556979122922720.5357142857147 2578.6354993433282719.0 2573.8239560773412718.3112244897957 2568.98024664931242708.385714285714 2564.1036563043662700.576530612245 2559.19344795180042699.0 2554.2488611895792698.319387755102 2549.2691112748172698.0 2544.253388036632697.3234693877553 2539.20085472739772696.3255102040816 2534.11064680818252694.6551020408165 2528.98187066369432683.9438775510203 2523.81360224181162673.6530612244896 2518.60488561224432667.668367346939 2513.3547314384762661.3500000000004 2508.0621153566042650.3908163265305 2502.7259762541482641.3785714285714 2497.34521444128952627.8112244897957 2491.91868970632462622.0 2486.4452192463662620.691836734694 2480.92357546351742613.4795918367345 2475.3524836158272609.3500000000004 2469.73061931131772607.0561224489793 2464.05660583227752605.354081632653 2458.3290112757472599.8489795918367 2452.54634549475852595.716326530612 2446.70705682334162591.8010204081634 2440.8095285665942584.2602040816328 2434.8520752351812579.7285714285713 2428.83293850149272565.692857142857 2422.7502828522622554.2102040816326 2416.6021909097422547.592857142857 2410.3866583904952545.0 2404.1015886673922541.24693877551 2397.74478689656142519.0489795918365 2391.31395366662352505.7571428571428 2384.80667812255342500.044897959184 2378.22043051088532490.826530612245 2371.55255408651152483.923469387755 2364.80025631398532459.922448979592 2357.9605992878382434.9979591836736 2351.0304892867972426.1724489795915 2344.0066653657222420.75 2336.88568687633052417.3948979591837 2329.6639197930952410.969387755102 2322.33752170363052405.1969387755103 2314.90242530314572401.0051020408164 2307.35432020947842394.2244897959185 2299.68863288835342373.7479591836736 2291.90050444700142360.8142857142857 2283.98476601722952355.864285714286 2275.93591140536772344.168367346939 2267.74806663482652332.1326530612246 2259.41495594558462309.8744897959186 2250.9298637417212283.5989795918367 2242.2855918903982264.1295918367346 2233.4744116703152254.1071428571427 2224.48800954029962230.668367346939 2215.3174257442462213.851020408163 2205.9529845802192198.688775510204 2196.3842149307112165.183673469388 2186.5997593665622136.0642857142857 2176.58726978454252110.576530612245 2166.33328709908162094.614285714286 2155.8231019571682090.8755102040814 2145.04059274881462040.7020408163266 2133.9680362991492000.3255102040816 2122.5858854918471969.5255102040815 2110.87250660484641941.5673469387755 2098.8038672242971905.9816326530613 2086.353163082571876.7 2073.4903688164861833.9989795918368 2060.1816931414971795.5408163265306 2046.38891282078251785.0173469387755 2032.0685513894691771.330612244898 2017.1708568485361751.584693877551 2001.63851591066211699.0551020408163 1985.40501844256851638.8928571428573 1968.39255067638851605.7255102040817 1950.50924335384021581.7091836734694 1931.6455209180421557.2897959183674 1911.6691725727821543.362244897959 1890.41856443932261519.454081632653 1867.693077413251463.880612244898 1843.2392796562921415.8785714285714 1816.73031054567881362.0071428571428 1787.73401068580051324.4826530612245 1755.66146130831271261.6479591836735 1719.67932317406441108.5591836734693 1678.550088648625999.573469387755 1630.3141949645815951.9765306122449 1571.576594619839893.5714285714287 1495.596335379243785.204081632653 1385.425344131971700.454081632653 1166.07580745253660.4336734693877 h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? 0 1000 2000 3000 4000 5000 0 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 4200 4400 4600 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360 1380 1400 1420 1440 1460 1480 1500 1520 1540 1560 1580 1600 1620 1640 1660 1680 1700 1720 1740 1760 1780 1800 1820 1840 1860 1880 1900 1920 1940 1960 1980 2000 2020 2040 2060 2080 2100 2120 2140 2160 2180 2200 2220 2240 2260 2280 2300 2320 2340 2360 2380 2400 2420 2440 2460 2480 2500 2520 2540 2560 2580 2600 2620 2640 2660 2680 2700 2720 2740 2760 2780 2800 2820 2840 2860 2880 2900 2920 2940 2960 2980 3000 3020 3040 3060 3080 3100 3120 3140 3160 3180 3200 3220 3240 3260 3280 3300 3320 3340 3360 3380 3400 3420 3440 3460 3480 3500 3520 3540 3560 3580 3600 3620 3640 3660 3680 3700 3720 3740 3760 3780 3800 3820 3840 3860 3880 3900 3920 3940 3960 3980 4000 4020 4040 4060 4080 4100 4120 4140 4160 4180 4200 4220 4240 4260 4280 4300 4320 4340 4360 4380 4400 4420 4440 4460 4480 4500 4520 4540 0 5000 Birth weight (g)
Figure 1: QQ-plots against the standard Normal distribution.

2.3 Linearity

Let’s graphically check if there is a linear relationship between gestation time and birth weight.

plot(
    births,
    x = :gestwks,
    y = :bweight,
    Geom.point(), Geom.smooth(smoothing = 0.9),
    Guide.xlabel("Gestational weeks"),
    Guide.ylabel("Birth weight (g)")
)
Gestational weeks 20 25 30 35 40 45 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 20.0 20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.9 22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.2 26.3 26.4 26.5 26.6 26.7 26.8 26.9 27.0 27.1 27.2 27.3 27.4 27.5 27.6 27.7 27.8 27.9 28.0 28.1 28.2 28.3 28.4 28.5 28.6 28.7 28.8 28.9 29.0 29.1 29.2 29.3 29.4 29.5 29.6 29.7 29.8 29.9 30.0 30.1 30.2 30.3 30.4 30.5 30.6 30.7 30.8 30.9 31.0 31.1 31.2 31.3 31.4 31.5 31.6 31.7 31.8 31.9 32.0 32.1 32.2 32.3 32.4 32.5 32.6 32.7 32.8 32.9 33.0 33.1 33.2 33.3 33.4 33.5 33.6 33.7 33.8 33.9 34.0 34.1 34.2 34.3 34.4 34.5 34.6 34.7 34.8 34.9 35.0 35.1 35.2 35.3 35.4 35.5 35.6 35.7 35.8 35.9 36.0 36.1 36.2 36.3 36.4 36.5 36.6 36.7 36.8 36.9 37.0 37.1 37.2 37.3 37.4 37.5 37.6 37.7 37.8 37.9 38.0 38.1 38.2 38.3 38.4 38.5 38.6 38.7 38.8 38.9 39.0 39.1 39.2 39.3 39.4 39.5 39.6 39.7 39.8 39.9 40.0 40.1 40.2 40.3 40.4 40.5 40.6 40.7 40.8 40.9 41.0 41.1 41.2 41.3 41.4 41.5 41.6 41.7 41.8 41.9 42.0 42.1 42.2 42.3 42.4 42.5 42.6 42.7 42.8 42.9 43.0 43.1 43.2 43.3 43.4 43.5 43.6 43.7 43.8 43.9 44.0 44.1 44.2 44.3 44.4 44.5 44.6 44.7 44.8 44.9 45.0 20 30 40 50 37.97000122070312918.0 39.91999816894533178.0 38.53054.0 38.02999877929693187.0 38.45000076293952852.0 41.00999832153322968.0 38.02999877929693349.0 39.43000030517583322.0 38.90999984741213542.0 39.65999984741213948.0 37.59000015258793237.0 38.25999832153323172.0 38.09000015258793152.0 40.08000183105473409.0 38.09000015258792552.0 39.22000122070313095.0 39.54000091552733061.0 38.84999847412113455.0 39.52000045776372595.0 39.88000106811522843.0 39.70000076293952963.0 34.34000015258792417.0 39.79999923706052639.0 39.5600013732912878.0 31.70999908447271938.0 40.66999816894533718.0 40.29999923706054516.0 40.4399986267093611.0 37.09999847412113565.0 38.47999954223633337.0 38.93000030517583122.0 40.09000015258794300.0 39.02000045776373087.0 39.5600013732913770.0 39.86000061035163486.0 38.90000152587893757.0 36.09000015258792949.0 41.13000106811524182.0 41.02000045776374041.0 39.20000076293953102.0 41.3100013732913306.0 41.25999832153324304.0 38.753294.0 39.0600013732913419.0 39.18000030517584197.0 39.43000030517583042.0 40.02999877929692885.0 40.61000061035164133.0 35.97000122070312719.0 40.20000076293954224.0 37.9399986267092944.0 40.81999969482423551.0 40.77999877929693122.0 40.61999893188483386.0 38.97999954223633601.0 31.37000083923342098.0 40.18000030517583376.0 39.9399986267093830.0 38.45000076293952399.0 39.90000152587893581.0 40.93000030517583064.0 31.29000091552731324.0 39.43000030517583463.0 39.74000167846683179.0 37.86000061035162944.0 40.1899986267093222.0 41.99000167846683184.0 39.56999969482422353.0 36.36999893188483093.0 39.90000152587893457.0 38.86000061035163140.0 34.1899986267091874.0 40.34999847412113545.0 42.20000076293953082.0 38.68000030517582978.0 37.36000061035162362.0 38.66999816894532801.0 37.54000091552732697.0 40.65999984741213851.0 40.27000045776372969.0 39.59999847412113350.0 40.15000152587893497.0 39.74000167846683516.0 36.27999877929693559.0 39.49000167846683134.0 39.38000106811523383.0 35.95000076293952407.0 39.90000152587893337.0 39.70000076293952797.0 34.0600013732912497.0 37.11000061035162622.0 40.13000106811523733.0 40.36000061035163432.0 40.45000076293953519.0 39.77000045776373041.0 38.83000183105473404.0 39.63999938964843082.0 38.36000061035163704.0 37.90999984741214035.0 37.81999969482422969.0 37.95999908447273562.0 40.38000106811522968.0 36.99000167846682732.0 38.25999832153323160.0 38.04999923706054226.0 39.753200.0 40.11999893188483370.0 38.36000061035163257.0 39.95999908447273090.0 39.75999832153323207.0 39.56999969482424287.0 40.56999969482423024.0 38.15000152587892863.0 39.49000167846683425.0 37.95999908447272943.0 37.65000152587893045.0 38.6899986267092924.0 37.27000045776373333.0 38.95000076293953102.0 36.4399986267092666.0 39.40000152587893193.0 38.752744.0 40.59000015258793286.0 39.34999847412112769.0 38.77999877929693695.0 39.16999816894533282.0 32.52999877929691541.0 38.22999954223632784.0 38.88999938964843804.0 37.79000091552732694.0 36.22999954223632425.0 37.52999877929692890.0 33.22999954223632659.0 41.02999877929693621.0 42.04999923706053980.0 40.02999877929693646.0 38.90999984741212914.0 38.97000122070313154.0 32.40999984741211431.0 41.04999923706054179.0 39.13000106811524319.0 40.47999954223633435.0 40.95000076293953398.0 37.79000091552733683.0 41.04000091552733730.0 38.29000091552733331.0 38.22999954223632905.0 39.04000091552732558.0 40.20999908447272859.0 35.52606.0 38.54999923706053156.0 39.95999908447273249.0 39.63000106811523040.0 38.86999893188483392.0 38.06999969482422855.0 40.72999954223633184.0 38.72000122070313192.0 36.24000167846682736.0 34.66999816894531325.0 39.22000122070312605.0 41.38000106811522699.0 38.15999984741213075.0 35.40999984741212274.0 38.04000091552732804.0 39.61999893188483625.0 39.50999832153323004.0 39.75999832153323428.0 30.8500003814697924.0 38.6899986267093767.0 40.79000091552733739.0 38.77000045776372646.0 38.22999954223633092.0 39.49000167846683249.0 40.34999847412113451.0 35.68000030517581801.0 40.09000015258793007.0 40.06999969482424553.0 41.09999847412113365.0 37.84000015258792719.0 39.8100013732913727.0 40.70000076293953349.0 40.63999938964843376.0 30.52000045776371595.0 35.27000045776371500.0 36.9399986267092297.0 41.18000030517583754.0 41.70999908447273783.0 38.90000152587893546.0 39.04000091552732989.0 39.65000152587893734.0 37.90000152587893591.0 40.63999938964843502.0 41.16999816894533290.0 38.5600013732913576.0 38.47999954223633813.0 37.43000030517582188.0 40.97000122070313770.0 40.47999954223633386.0 39.61000061035163379.0 40.34000015258792953.0 37.33000183105472802.0 40.00999832153322866.0 39.6899986267093291.0 40.81999969482423450.0 37.83000183105473590.0 37.66999816894532446.0 39.65000152587893105.0 41.79000091552734423.0 39.20999908447272974.0 38.99000167846682982.0 38.50999832153323323.0 40.74000167846682961.0 37.41999816894532360.0 32.8100013732911618.0 39.84999847412113664.0 38.99000167846683197.0 39.84999847412113003.0 39.90999984741213096.0 30.64999961853031764.0 24.6900005340576864.0 37.45999908447272938.0 40.5600013732913446.0 37.22000122070312090.0 37.49000167846683558.0 37.13000106811522622.0 37.54999923706052482.0 39.91999816894533723.0 40.753023.0 38.65999984741213505.0 40.99000167846683694.0 39.54000091552734205.0 38.02000045776373554.0 34.02000045776371570.0 40.253250.0 42.86000061035163695.0 38.25999832153322699.0 37.04999923706052991.0 38.4399986267092831.0 40.79999923706053311.0 37.33000183105472590.0 37.45999908447272879.0 30.7099990844727693.0 39.09000015258793269.0 37.74000167846682718.0 40.74000167846683919.0 40.45000076293953163.0 39.20000076293953254.0 38.54999923706052729.0 41.29000091552733976.0 38.27000045776373078.0 40.79999923706052698.0 39.53647.0 37.56999969482423099.0 39.11999893188483041.0 34.63999938964843009.0 39.52000045776373943.0 40.79999923706054436.0 39.04999923706052913.0 43.15999984741213486.0 40.41999816894533768.0 38.753367.0 39.70000076293952768.0 39.4399986267093341.0 39.97999954223633138.0 38.18000030517583096.0 36.81999969482422545.0 38.34000015258793385.0 40.33000183105473882.0 27.9899997711182981.0 38.99000167846682951.0 39.9399986267093216.0 39.41999816894532837.0 39.84999847412113079.0 36.9399986267092404.0 34.13999938964842328.0 41.95999908447273141.0 38.9399986267094122.0 32.63999938964841741.0 40.34999847412113463.0 37.77999877929693571.0 27.3299999237061708.0 37.59000015258792992.0 38.88000106811523134.0 39.13999938964843109.0 36.15999984741213188.0 35.61999893188482505.0 38.253296.0 39.79999923706053518.0 39.8100013732914340.0 38.91999816894533448.0 39.66999816894533005.0 40.47999954223633807.0 33.66999816894531880.0 42.29999923706054131.0 36.45000076293952698.0 38.36000061035163561.0 40.93000030517583180.0 39.84000015258793184.0 40.04000091552733526.0 41.02679.0 37.9399986267092842.0 38.0600013732912252.0 40.04000091552733550.0 39.02000045776372539.0 32.47000122070311402.0 41.84000015258793696.0 41.22000122070313146.0 39.77000045776373051.0 38.40999984741212257.0 36.40999984741213606.0 40.53126.0 39.75999832153322127.0 39.93000030517582609.0 28.04000091552731019.0 35.72999954223632545.0 37.97000122070312704.0 37.88999938964843260.0 40.40999984741213117.0 38.59999847412113575.0 39.70999908447273582.0 37.74000167846681791.0 37.86000061035163001.0 40.06999969482423503.0 38.58000183105473501.0 38.33000183105474057.0 37.38999938964842762.0 40.02999877929693824.0 34.70000076293952751.0 40.54999923706053117.0 36.84999847412111999.0 37.63000106811523261.0 40.22999954223633027.0 37.22000122070312428.0 37.09999847412112740.0 37.16999816894533007.0 40.88999938964843567.0 38.58000183105472338.0 38.6899986267093360.0 38.59999847412113471.0 40.99000167846683636.0 41.88000106811523621.0 39.34999847412113292.0 41.02000045776373449.0 39.75999832153322922.0 39.52000045776372995.0 41.11000061035162990.0 37.58000183105473461.0 39.88000106811522579.0 37.74000167846683676.0 40.36000061035163985.0 39.59999847412113233.0 40.29000091552733288.0 26.9500007629395628.0 37.04000091552733178.0 40.90000152587893267.0 40.54069.0 37.65000152587892764.0 37.88000106811523552.0 36.91999816894532935.0 40.72999954223633879.0 37.25999832153322959.0 40.11000061035163423.0 37.40000152587893545.0 39.753727.0 38.63000106811522926.0 39.45000076293953261.0 39.63999938964842610.0 39.86000061035163467.0 40.54999923706053062.0 41.11000061035163149.0 37.84999847412111546.0 35.13999938964841663.0 39.83000183105474092.0 40.09999847412113592.0 40.81999969482423995.0 38.74000167846683932.0 37.95999908447272092.0 36.27000045776372487.0 40.84000015258793183.0 36.54000091552733198.0 37.47000122070313605.0 40.15000152587892950.0 41.04999923706053593.0 39.11000061035162894.0 38.25999832153322911.0 39.09999847412113332.0 37.08000183105472830.0 37.70000076293953773.0 41.04000091552733715.0 39.45999908447273138.0 39.49000167846683226.0 38.09000015258792796.0 39.00999832153323784.0 39.84999847412113576.0 39.97000122070313942.0 38.18000030517583259.0 42.0600013732913244.0 39.86000061035163430.0 34.86999893188482671.0 40.58000183105473092.0 36.36999893188482418.0 40.18000030517584027.0 40.0600013732913603.0 38.91999816894533064.0 37.33000183105472893.0 38.93000030517584071.0 39.00999832153324141.0 41.24000167846683316.0 38.47999954223632507.0 40.47999954223633338.0 38.13999938964843451.0 38.58000183105473341.0 38.36999893188482215.0 38.68000030517584512.0 38.27000045776373571.0 39.04000091552733190.0 40.36999893188483409.0 34.66999816894532597.0 34.59000015258792696.0 37.74000167846683392.0 37.16999816894533189.0 39.56999969482423354.0 37.88999938964841946.0 41.68000030517583385.0 38.27000045776372929.0 39.61999893188482921.0 38.20999908447273296.0 39.95000076293953303.0 36.34999847412112797.0 37.68000030517582213.0 36.47999954223632002.0 37.61999893188482849.0 40.91999816894533886.0 40.03375.0 40.02999877929694501.0 38.90000152587892887.0 39.58000183105473465.0 38.4399986267093079.0 38.63999938964843774.0 38.4399986267092148.0 39.43000030517583542.0 40.63000106811523678.0 39.1899986267093305.0 35.70000076293952581.0 39.58000183105473234.0 37.4399986267093184.0 40.36000061035163592.0 39.04000091552733743.0 38.50999832153323120.0 37.86999893188483503.0 40.66999816894533053.0 38.79999923706053007.0 39.34999847412113279.0 40.9399986267093652.0 39.11999893188483566.0 39.47000122070313509.0 40.45999908447273911.0 36.40000152587892391.0 38.50999832153322887.0 39.18000030517583942.0 39.70999908447274022.0 40.45000076293951780.0 41.65999984741213739.0 36.52999877929693164.0 39.38000106811523798.0 39.54999923706053585.0 40.13999938964842844.0 40.1899986267093753.0 38.72000122070313306.0 32.79999923706051203.0 39.27000045776372894.0 39.45000076293953283.0 40.74000167846683573.0 38.99000167846683804.0 39.34999847412113351.0 38.95999908447273035.0 39.22999954223633662.0 40.04999923706053039.0 41.02000045776373001.0 38.97000122070312724.0 40.91999816894534020.0 39.33000183105473405.0 42.02999877929693960.0 40.20999908447273773.0 42.13999938964843628.0 40.97000122070313673.0 38.88999938964843200.0 39.79999923706053751.0 38.15000152587892620.0 38.52000045776372974.0 h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? 0 1000 2000 3000 4000 5000 0 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 4200 4400 4600 4800 5000 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360 1380 1400 1420 1440 1460 1480 1500 1520 1540 1560 1580 1600 1620 1640 1660 1680 1700 1720 1740 1760 1780 1800 1820 1840 1860 1880 1900 1920 1940 1960 1980 2000 2020 2040 2060 2080 2100 2120 2140 2160 2180 2200 2220 2240 2260 2280 2300 2320 2340 2360 2380 2400 2420 2440 2460 2480 2500 2520 2540 2560 2580 2600 2620 2640 2660 2680 2700 2720 2740 2760 2780 2800 2820 2840 2860 2880 2900 2920 2940 2960 2980 3000 3020 3040 3060 3080 3100 3120 3140 3160 3180 3200 3220 3240 3260 3280 3300 3320 3340 3360 3380 3400 3420 3440 3460 3480 3500 3520 3540 3560 3580 3600 3620 3640 3660 3680 3700 3720 3740 3760 3780 3800 3820 3840 3860 3880 3900 3920 3940 3960 3980 4000 4020 4040 4060 4080 4100 4120 4140 4160 4180 4200 4220 4240 4260 4280 4300 4320 4340 4360 4380 4400 4420 4440 4460 4480 4500 4520 4540 4560 4580 4600 4620 4640 4660 4680 4700 4720 4740 4760 4780 4800 4820 4840 4860 4880 4900 4920 4940 4960 4980 5000 0 5000 Birth weight (g)
Figure 2: Relationship between gestation time and birth weight from the births dataset. The curve represents a loess fit.
Question

What is your observation about linearity from your scatter plot?

Answer

There is a linear relationship, but only for the middle part of the curve. The curve is clearly non-linear and more like an S-shape characteristic of human growth.

Let’s construct the plot for the section where linearity is more evident.

plot(
    @subset(births, :gestwks > 31, :gestwks < 40),
    x = :gestwks,
    y = :bweight,
    Geom.point(), Geom.smooth(smoothing = 0.9),
    Guide.xlabel("Gestational weeks"),
    Guide.ylabel("Birth weight (g)")
)
Gestational weeks 30 35 40 30.0 30.5 31.0 31.5 32.0 32.5 33.0 33.5 34.0 34.5 35.0 35.5 36.0 36.5 37.0 37.5 38.0 38.5 39.0 39.5 40.0 29.95 30.00 30.05 30.10 30.15 30.20 30.25 30.30 30.35 30.40 30.45 30.50 30.55 30.60 30.65 30.70 30.75 30.80 30.85 30.90 30.95 31.00 31.05 31.10 31.15 31.20 31.25 31.30 31.35 31.40 31.45 31.50 31.55 31.60 31.65 31.70 31.75 31.80 31.85 31.90 31.95 32.00 32.05 32.10 32.15 32.20 32.25 32.30 32.35 32.40 32.45 32.50 32.55 32.60 32.65 32.70 32.75 32.80 32.85 32.90 32.95 33.00 33.05 33.10 33.15 33.20 33.25 33.30 33.35 33.40 33.45 33.50 33.55 33.60 33.65 33.70 33.75 33.80 33.85 33.90 33.95 34.00 34.05 34.10 34.15 34.20 34.25 34.30 34.35 34.40 34.45 34.50 34.55 34.60 34.65 34.70 34.75 34.80 34.85 34.90 34.95 35.00 35.05 35.10 35.15 35.20 35.25 35.30 35.35 35.40 35.45 35.50 35.55 35.60 35.65 35.70 35.75 35.80 35.85 35.90 35.95 36.00 36.05 36.10 36.15 36.20 36.25 36.30 36.35 36.40 36.45 36.50 36.55 36.60 36.65 36.70 36.75 36.80 36.85 36.90 36.95 37.00 37.05 37.10 37.15 37.20 37.25 37.30 37.35 37.40 37.45 37.50 37.55 37.60 37.65 37.70 37.75 37.80 37.85 37.90 37.95 38.00 38.05 38.10 38.15 38.20 38.25 38.30 38.35 38.40 38.45 38.50 38.55 38.60 38.65 38.70 38.75 38.80 38.85 38.90 38.95 39.00 39.05 39.10 39.15 39.20 39.25 39.30 39.35 39.40 39.45 39.50 39.55 39.60 39.65 39.70 39.75 39.80 39.85 39.90 39.95 40.00 30 40 37.97000122070312918.0 39.91999816894533178.0 38.53054.0 38.02999877929693187.0 38.45000076293952852.0 38.02999877929693349.0 39.43000030517583322.0 38.90999984741213542.0 39.65999984741213948.0 37.59000015258793237.0 38.25999832153323172.0 38.09000015258793152.0 38.09000015258792552.0 39.22000122070313095.0 39.54000091552733061.0 38.84999847412113455.0 39.52000045776372595.0 39.88000106811522843.0 39.70000076293952963.0 34.34000015258792417.0 39.79999923706052639.0 39.5600013732912878.0 31.70999908447271938.0 37.09999847412113565.0 38.47999954223633337.0 38.93000030517583122.0 39.02000045776373087.0 39.5600013732913770.0 39.86000061035163486.0 38.90000152587893757.0 36.09000015258792949.0 39.20000076293953102.0 38.753294.0 39.0600013732913419.0 39.18000030517584197.0 39.43000030517583042.0 35.97000122070312719.0 37.9399986267092944.0 38.97999954223633601.0 31.37000083923342098.0 39.9399986267093830.0 38.45000076293952399.0 39.90000152587893581.0 31.29000091552731324.0 39.43000030517583463.0 39.74000167846683179.0 37.86000061035162944.0 39.56999969482422353.0 36.36999893188483093.0 39.90000152587893457.0 38.86000061035163140.0 34.1899986267091874.0 38.68000030517582978.0 37.36000061035162362.0 38.66999816894532801.0 37.54000091552732697.0 39.59999847412113350.0 39.74000167846683516.0 36.27999877929693559.0 39.49000167846683134.0 39.38000106811523383.0 35.95000076293952407.0 39.90000152587893337.0 39.70000076293952797.0 34.0600013732912497.0 37.11000061035162622.0 39.77000045776373041.0 38.83000183105473404.0 39.63999938964843082.0 38.36000061035163704.0 37.90999984741214035.0 37.81999969482422969.0 37.95999908447273562.0 36.99000167846682732.0 38.25999832153323160.0 38.04999923706054226.0 39.753200.0 38.36000061035163257.0 39.95999908447273090.0 39.75999832153323207.0 39.56999969482424287.0 38.15000152587892863.0 39.49000167846683425.0 37.95999908447272943.0 37.65000152587893045.0 38.6899986267092924.0 37.27000045776373333.0 38.95000076293953102.0 36.4399986267092666.0 39.40000152587893193.0 38.752744.0 39.34999847412112769.0 38.77999877929693695.0 39.16999816894533282.0 32.52999877929691541.0 38.22999954223632784.0 38.88999938964843804.0 37.79000091552732694.0 36.22999954223632425.0 37.52999877929692890.0 33.22999954223632659.0 38.90999984741212914.0 38.97000122070313154.0 32.40999984741211431.0 39.13000106811524319.0 37.79000091552733683.0 38.29000091552733331.0 38.22999954223632905.0 39.04000091552732558.0 35.52606.0 38.54999923706053156.0 39.95999908447273249.0 39.63000106811523040.0 38.86999893188483392.0 38.06999969482422855.0 38.72000122070313192.0 36.24000167846682736.0 34.66999816894531325.0 39.22000122070312605.0 38.15999984741213075.0 35.40999984741212274.0 38.04000091552732804.0 39.61999893188483625.0 39.50999832153323004.0 39.75999832153323428.0 38.6899986267093767.0 38.77000045776372646.0 38.22999954223633092.0 39.49000167846683249.0 35.68000030517581801.0 37.84000015258792719.0 39.8100013732913727.0 35.27000045776371500.0 36.9399986267092297.0 38.90000152587893546.0 39.04000091552732989.0 39.65000152587893734.0 37.90000152587893591.0 38.5600013732913576.0 38.47999954223633813.0 37.43000030517582188.0 39.61000061035163379.0 37.33000183105472802.0 39.6899986267093291.0 37.83000183105473590.0 37.66999816894532446.0 39.65000152587893105.0 39.20999908447272974.0 38.99000167846682982.0 38.50999832153323323.0 37.41999816894532360.0 32.8100013732911618.0 39.84999847412113664.0 38.99000167846683197.0 39.84999847412113003.0 39.90999984741213096.0 37.45999908447272938.0 37.22000122070312090.0 37.49000167846683558.0 37.13000106811522622.0 37.54999923706052482.0 39.91999816894533723.0 38.65999984741213505.0 39.54000091552734205.0 38.02000045776373554.0 34.02000045776371570.0 38.25999832153322699.0 37.04999923706052991.0 38.4399986267092831.0 37.33000183105472590.0 37.45999908447272879.0 39.09000015258793269.0 37.74000167846682718.0 39.20000076293953254.0 38.54999923706052729.0 38.27000045776373078.0 39.53647.0 37.56999969482423099.0 39.11999893188483041.0 34.63999938964843009.0 39.52000045776373943.0 39.04999923706052913.0 38.753367.0 39.70000076293952768.0 39.4399986267093341.0 39.97999954223633138.0 38.18000030517583096.0 36.81999969482422545.0 38.34000015258793385.0 38.99000167846682951.0 39.9399986267093216.0 39.41999816894532837.0 39.84999847412113079.0 36.9399986267092404.0 34.13999938964842328.0 38.9399986267094122.0 32.63999938964841741.0 37.77999877929693571.0 37.59000015258792992.0 38.88000106811523134.0 39.13999938964843109.0 36.15999984741213188.0 35.61999893188482505.0 38.253296.0 39.79999923706053518.0 39.8100013732914340.0 38.91999816894533448.0 39.66999816894533005.0 33.66999816894531880.0 36.45000076293952698.0 38.36000061035163561.0 39.84000015258793184.0 37.9399986267092842.0 38.0600013732912252.0 39.02000045776372539.0 32.47000122070311402.0 39.77000045776373051.0 38.40999984741212257.0 36.40999984741213606.0 39.75999832153322127.0 39.93000030517582609.0 35.72999954223632545.0 37.97000122070312704.0 37.88999938964843260.0 38.59999847412113575.0 39.70999908447273582.0 37.74000167846681791.0 37.86000061035163001.0 38.58000183105473501.0 38.33000183105474057.0 37.38999938964842762.0 34.70000076293952751.0 36.84999847412111999.0 37.63000106811523261.0 37.22000122070312428.0 37.09999847412112740.0 37.16999816894533007.0 38.58000183105472338.0 38.6899986267093360.0 38.59999847412113471.0 39.34999847412113292.0 39.75999832153322922.0 39.52000045776372995.0 37.58000183105473461.0 39.88000106811522579.0 37.74000167846683676.0 39.59999847412113233.0 37.04000091552733178.0 37.65000152587892764.0 37.88000106811523552.0 36.91999816894532935.0 37.25999832153322959.0 37.40000152587893545.0 39.753727.0 38.63000106811522926.0 39.45000076293953261.0 39.63999938964842610.0 39.86000061035163467.0 37.84999847412111546.0 35.13999938964841663.0 39.83000183105474092.0 38.74000167846683932.0 37.95999908447272092.0 36.27000045776372487.0 36.54000091552733198.0 37.47000122070313605.0 39.11000061035162894.0 38.25999832153322911.0 39.09999847412113332.0 37.08000183105472830.0 37.70000076293953773.0 39.45999908447273138.0 39.49000167846683226.0 38.09000015258792796.0 39.00999832153323784.0 39.84999847412113576.0 39.97000122070313942.0 38.18000030517583259.0 39.86000061035163430.0 34.86999893188482671.0 36.36999893188482418.0 38.91999816894533064.0 37.33000183105472893.0 38.93000030517584071.0 39.00999832153324141.0 38.47999954223632507.0 38.13999938964843451.0 38.58000183105473341.0 38.36999893188482215.0 38.68000030517584512.0 38.27000045776373571.0 39.04000091552733190.0 34.66999816894532597.0 34.59000015258792696.0 37.74000167846683392.0 37.16999816894533189.0 39.56999969482423354.0 37.88999938964841946.0 38.27000045776372929.0 39.61999893188482921.0 38.20999908447273296.0 39.95000076293953303.0 36.34999847412112797.0 37.68000030517582213.0 36.47999954223632002.0 37.61999893188482849.0 38.90000152587892887.0 39.58000183105473465.0 38.4399986267093079.0 38.63999938964843774.0 38.4399986267092148.0 39.43000030517583542.0 39.1899986267093305.0 35.70000076293952581.0 39.58000183105473234.0 37.4399986267093184.0 39.04000091552733743.0 38.50999832153323120.0 37.86999893188483503.0 38.79999923706053007.0 39.34999847412113279.0 39.11999893188483566.0 39.47000122070313509.0 36.40000152587892391.0 38.50999832153322887.0 39.18000030517583942.0 39.70999908447274022.0 36.52999877929693164.0 39.38000106811523798.0 39.54999923706053585.0 38.72000122070313306.0 32.79999923706051203.0 39.27000045776372894.0 39.45000076293953283.0 38.99000167846683804.0 39.34999847412113351.0 38.95999908447273035.0 39.22999954223633662.0 38.97000122070312724.0 39.33000183105473405.0 38.88999938964843200.0 39.79999923706053751.0 38.15000152587892620.0 38.52000045776372974.0 h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? 0 1000 2000 3000 4000 5000 0 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 4200 4400 4600 4800 5000 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360 1380 1400 1420 1440 1460 1480 1500 1520 1540 1560 1580 1600 1620 1640 1660 1680 1700 1720 1740 1760 1780 1800 1820 1840 1860 1880 1900 1920 1940 1960 1980 2000 2020 2040 2060 2080 2100 2120 2140 2160 2180 2200 2220 2240 2260 2280 2300 2320 2340 2360 2380 2400 2420 2440 2460 2480 2500 2520 2540 2560 2580 2600 2620 2640 2660 2680 2700 2720 2740 2760 2780 2800 2820 2840 2860 2880 2900 2920 2940 2960 2980 3000 3020 3040 3060 3080 3100 3120 3140 3160 3180 3200 3220 3240 3260 3280 3300 3320 3340 3360 3380 3400 3420 3440 3460 3480 3500 3520 3540 3560 3580 3600 3620 3640 3660 3680 3700 3720 3740 3760 3780 3800 3820 3840 3860 3880 3900 3920 3940 3960 3980 4000 4020 4040 4060 4080 4100 4120 4140 4160 4180 4200 4220 4240 4260 4280 4300 4320 4340 4360 4380 4400 4420 4440 4460 4480 4500 4520 4540 4560 4580 4600 4620 4640 4660 4680 4700 4720 4740 4760 4780 4800 4820 4840 4860 4880 4900 4920 4940 4960 4980 5000 0 5000 Birth weight (g)
Figure 3: Relationship between gestation time (restricted between 31 and 40 weeks) and birth weight from the data births. The black curve represents a loess fit.

Let’s generate a new dataset with the subset of observations that are within the linear section of the relationship between gestation period and birth weight. For this subset, we will select only variables of interest.

births |> names
8-element Vector{String}:
 "id"
 "bweight"
 "lowbw"
 "gestwks"
 "preterm"
 "matage"
 "hyp"
 "sex"
babies = @select(
  @subset(births, :gestwks .> 31, :gestwks .< 40),
  {Not([:id, :preterm, :lowbw])}
)

rename!(
  babies,
  :gestwks => :Gestation,
  :matage => :Age,
  :hyp => :Hypertension,
  :sex => :Sex
)
babies |> head
5×5 DataFrame
Row bweight Gestation Age Hypertension Sex
Float64 Float64 Float64 Float64 Float64
1 2974.0 38.52 34.0 0.0 2.0
2 2620.0 38.15 35.0 0.0 2.0
3 3751.0 39.8 31.0 0.0 1.0
4 3200.0 38.89 33.0 1.0 1.0
5 3405.0 39.33 39.0 0.0 1.0
babies_cat = @select(
  @subset(births2, :Gestation .> 31, :Gestation .< 40),
  {Not([:id, :lowbw, :preterm, :low])}
)

babies_cat |> head
5×5 DataFrame
Row bweight Gestation Age Hypertension Sex
Float64 Float64 Float64 Cat… Cat…
1 2974.0 38.52 34.0 No hypertension Female
2 2620.0 38.15 35.0 No hypertension Female
3 3751.0 39.8 31.0 No hypertension Male
4 3200.0 38.89 33.0 Hypertension Male
5 3405.0 39.33 39.0 No hypertension Male

2.4 Interactions

We will check for potential interactions graphically. Let’s start with sex.

plot(
    babies_cat,
    x = :Gestation,
    y = :bweight,
    color = :Sex,
    Geom.point, Geom.smooth(method = :lm),
    Guide.xlabel("Gestational weeks"),
    Guide.ylabel("Birth weight (g)")
)
Gestational weeks 30 35 40 30.0 30.5 31.0 31.5 32.0 32.5 33.0 33.5 34.0 34.5 35.0 35.5 36.0 36.5 37.0 37.5 38.0 38.5 39.0 39.5 40.0 29.95 30.00 30.05 30.10 30.15 30.20 30.25 30.30 30.35 30.40 30.45 30.50 30.55 30.60 30.65 30.70 30.75 30.80 30.85 30.90 30.95 31.00 31.05 31.10 31.15 31.20 31.25 31.30 31.35 31.40 31.45 31.50 31.55 31.60 31.65 31.70 31.75 31.80 31.85 31.90 31.95 32.00 32.05 32.10 32.15 32.20 32.25 32.30 32.35 32.40 32.45 32.50 32.55 32.60 32.65 32.70 32.75 32.80 32.85 32.90 32.95 33.00 33.05 33.10 33.15 33.20 33.25 33.30 33.35 33.40 33.45 33.50 33.55 33.60 33.65 33.70 33.75 33.80 33.85 33.90 33.95 34.00 34.05 34.10 34.15 34.20 34.25 34.30 34.35 34.40 34.45 34.50 34.55 34.60 34.65 34.70 34.75 34.80 34.85 34.90 34.95 35.00 35.05 35.10 35.15 35.20 35.25 35.30 35.35 35.40 35.45 35.50 35.55 35.60 35.65 35.70 35.75 35.80 35.85 35.90 35.95 36.00 36.05 36.10 36.15 36.20 36.25 36.30 36.35 36.40 36.45 36.50 36.55 36.60 36.65 36.70 36.75 36.80 36.85 36.90 36.95 37.00 37.05 37.10 37.15 37.20 37.25 37.30 37.35 37.40 37.45 37.50 37.55 37.60 37.65 37.70 37.75 37.80 37.85 37.90 37.95 38.00 38.05 38.10 38.15 38.20 38.25 38.30 38.35 38.40 38.45 38.50 38.55 38.60 38.65 38.70 38.75 38.80 38.85 38.90 38.95 39.00 39.05 39.10 39.15 39.20 39.25 39.30 39.35 39.40 39.45 39.50 39.55 39.60 39.65 39.70 39.75 39.80 39.85 39.90 39.95 40.00 30 40 Female Male Sex 37.97000122070312918.0 39.91999816894533178.0 38.53054.0 38.02999877929693187.0 38.45000076293952852.0 38.02999877929693349.0 39.43000030517583322.0 38.90999984741213542.0 39.65999984741213948.0 37.59000015258793237.0 38.25999832153323172.0 38.09000015258793152.0 38.09000015258792552.0 39.22000122070313095.0 39.54000091552733061.0 38.84999847412113455.0 39.52000045776372595.0 39.88000106811522843.0 39.70000076293952963.0 34.34000015258792417.0 39.79999923706052639.0 39.5600013732912878.0 31.70999908447271938.0 37.09999847412113565.0 38.47999954223633337.0 38.93000030517583122.0 39.02000045776373087.0 39.5600013732913770.0 39.86000061035163486.0 38.90000152587893757.0 36.09000015258792949.0 39.20000076293953102.0 38.753294.0 39.0600013732913419.0 39.18000030517584197.0 39.43000030517583042.0 35.97000122070312719.0 37.9399986267092944.0 38.97999954223633601.0 31.37000083923342098.0 39.9399986267093830.0 38.45000076293952399.0 39.90000152587893581.0 31.29000091552731324.0 39.43000030517583463.0 39.74000167846683179.0 37.86000061035162944.0 39.56999969482422353.0 36.36999893188483093.0 39.90000152587893457.0 38.86000061035163140.0 34.1899986267091874.0 38.68000030517582978.0 37.36000061035162362.0 38.66999816894532801.0 37.54000091552732697.0 39.59999847412113350.0 39.74000167846683516.0 36.27999877929693559.0 39.49000167846683134.0 39.38000106811523383.0 35.95000076293952407.0 39.90000152587893337.0 39.70000076293952797.0 34.0600013732912497.0 37.11000061035162622.0 39.77000045776373041.0 38.83000183105473404.0 39.63999938964843082.0 38.36000061035163704.0 37.90999984741214035.0 37.81999969482422969.0 37.95999908447273562.0 36.99000167846682732.0 38.25999832153323160.0 38.04999923706054226.0 39.753200.0 38.36000061035163257.0 39.95999908447273090.0 39.75999832153323207.0 39.56999969482424287.0 38.15000152587892863.0 39.49000167846683425.0 37.95999908447272943.0 37.65000152587893045.0 38.6899986267092924.0 37.27000045776373333.0 38.95000076293953102.0 36.4399986267092666.0 39.40000152587893193.0 38.752744.0 39.34999847412112769.0 38.77999877929693695.0 39.16999816894533282.0 32.52999877929691541.0 38.22999954223632784.0 38.88999938964843804.0 37.79000091552732694.0 36.22999954223632425.0 37.52999877929692890.0 33.22999954223632659.0 38.90999984741212914.0 38.97000122070313154.0 32.40999984741211431.0 39.13000106811524319.0 37.79000091552733683.0 38.29000091552733331.0 38.22999954223632905.0 39.04000091552732558.0 35.52606.0 38.54999923706053156.0 39.95999908447273249.0 39.63000106811523040.0 38.86999893188483392.0 38.06999969482422855.0 38.72000122070313192.0 36.24000167846682736.0 34.66999816894531325.0 39.22000122070312605.0 38.15999984741213075.0 35.40999984741212274.0 38.04000091552732804.0 39.61999893188483625.0 39.50999832153323004.0 39.75999832153323428.0 38.6899986267093767.0 38.77000045776372646.0 38.22999954223633092.0 39.49000167846683249.0 35.68000030517581801.0 37.84000015258792719.0 39.8100013732913727.0 35.27000045776371500.0 36.9399986267092297.0 38.90000152587893546.0 39.04000091552732989.0 39.65000152587893734.0 37.90000152587893591.0 38.5600013732913576.0 38.47999954223633813.0 37.43000030517582188.0 39.61000061035163379.0 37.33000183105472802.0 39.6899986267093291.0 37.83000183105473590.0 37.66999816894532446.0 39.65000152587893105.0 39.20999908447272974.0 38.99000167846682982.0 38.50999832153323323.0 37.41999816894532360.0 32.8100013732911618.0 39.84999847412113664.0 38.99000167846683197.0 39.84999847412113003.0 39.90999984741213096.0 37.45999908447272938.0 37.22000122070312090.0 37.49000167846683558.0 37.13000106811522622.0 37.54999923706052482.0 39.91999816894533723.0 38.65999984741213505.0 39.54000091552734205.0 38.02000045776373554.0 34.02000045776371570.0 38.25999832153322699.0 37.04999923706052991.0 38.4399986267092831.0 37.33000183105472590.0 37.45999908447272879.0 39.09000015258793269.0 37.74000167846682718.0 39.20000076293953254.0 38.54999923706052729.0 38.27000045776373078.0 39.53647.0 37.56999969482423099.0 39.11999893188483041.0 34.63999938964843009.0 39.52000045776373943.0 39.04999923706052913.0 38.753367.0 39.70000076293952768.0 39.4399986267093341.0 39.97999954223633138.0 38.18000030517583096.0 36.81999969482422545.0 38.34000015258793385.0 38.99000167846682951.0 39.9399986267093216.0 39.41999816894532837.0 39.84999847412113079.0 36.9399986267092404.0 34.13999938964842328.0 38.9399986267094122.0 32.63999938964841741.0 37.77999877929693571.0 37.59000015258792992.0 38.88000106811523134.0 39.13999938964843109.0 36.15999984741213188.0 35.61999893188482505.0 38.253296.0 39.79999923706053518.0 39.8100013732914340.0 38.91999816894533448.0 39.66999816894533005.0 33.66999816894531880.0 36.45000076293952698.0 38.36000061035163561.0 39.84000015258793184.0 37.9399986267092842.0 38.0600013732912252.0 39.02000045776372539.0 32.47000122070311402.0 39.77000045776373051.0 38.40999984741212257.0 36.40999984741213606.0 39.75999832153322127.0 39.93000030517582609.0 35.72999954223632545.0 37.97000122070312704.0 37.88999938964843260.0 38.59999847412113575.0 39.70999908447273582.0 37.74000167846681791.0 37.86000061035163001.0 38.58000183105473501.0 38.33000183105474057.0 37.38999938964842762.0 34.70000076293952751.0 36.84999847412111999.0 37.63000106811523261.0 37.22000122070312428.0 37.09999847412112740.0 37.16999816894533007.0 38.58000183105472338.0 38.6899986267093360.0 38.59999847412113471.0 39.34999847412113292.0 39.75999832153322922.0 39.52000045776372995.0 37.58000183105473461.0 39.88000106811522579.0 37.74000167846683676.0 39.59999847412113233.0 37.04000091552733178.0 37.65000152587892764.0 37.88000106811523552.0 36.91999816894532935.0 37.25999832153322959.0 37.40000152587893545.0 39.753727.0 38.63000106811522926.0 39.45000076293953261.0 39.63999938964842610.0 39.86000061035163467.0 37.84999847412111546.0 35.13999938964841663.0 39.83000183105474092.0 38.74000167846683932.0 37.95999908447272092.0 36.27000045776372487.0 36.54000091552733198.0 37.47000122070313605.0 39.11000061035162894.0 38.25999832153322911.0 39.09999847412113332.0 37.08000183105472830.0 37.70000076293953773.0 39.45999908447273138.0 39.49000167846683226.0 38.09000015258792796.0 39.00999832153323784.0 39.84999847412113576.0 39.97000122070313942.0 38.18000030517583259.0 39.86000061035163430.0 34.86999893188482671.0 36.36999893188482418.0 38.91999816894533064.0 37.33000183105472893.0 38.93000030517584071.0 39.00999832153324141.0 38.47999954223632507.0 38.13999938964843451.0 38.58000183105473341.0 38.36999893188482215.0 38.68000030517584512.0 38.27000045776373571.0 39.04000091552733190.0 34.66999816894532597.0 34.59000015258792696.0 37.74000167846683392.0 37.16999816894533189.0 39.56999969482423354.0 37.88999938964841946.0 38.27000045776372929.0 39.61999893188482921.0 38.20999908447273296.0 39.95000076293953303.0 36.34999847412112797.0 37.68000030517582213.0 36.47999954223632002.0 37.61999893188482849.0 38.90000152587892887.0 39.58000183105473465.0 38.4399986267093079.0 38.63999938964843774.0 38.4399986267092148.0 39.43000030517583542.0 39.1899986267093305.0 35.70000076293952581.0 39.58000183105473234.0 37.4399986267093184.0 39.04000091552733743.0 38.50999832153323120.0 37.86999893188483503.0 38.79999923706053007.0 39.34999847412113279.0 39.11999893188483566.0 39.47000122070313509.0 36.40000152587892391.0 38.50999832153322887.0 39.18000030517583942.0 39.70999908447274022.0 36.52999877929693164.0 39.38000106811523798.0 39.54999923706053585.0 38.72000122070313306.0 32.79999923706051203.0 39.27000045776372894.0 39.45000076293953283.0 38.99000167846683804.0 39.34999847412113351.0 38.95999908447273035.0 39.22999954223633662.0 38.97000122070312724.0 39.33000183105473405.0 38.88999938964843200.0 39.79999923706053751.0 38.15000152587892620.0 38.52000045776372974.0 h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? 0 1000 2000 3000 4000 5000 0 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 4200 4400 4600 4800 5000 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360 1380 1400 1420 1440 1460 1480 1500 1520 1540 1560 1580 1600 1620 1640 1660 1680 1700 1720 1740 1760 1780 1800 1820 1840 1860 1880 1900 1920 1940 1960 1980 2000 2020 2040 2060 2080 2100 2120 2140 2160 2180 2200 2220 2240 2260 2280 2300 2320 2340 2360 2380 2400 2420 2440 2460 2480 2500 2520 2540 2560 2580 2600 2620 2640 2660 2680 2700 2720 2740 2760 2780 2800 2820 2840 2860 2880 2900 2920 2940 2960 2980 3000 3020 3040 3060 3080 3100 3120 3140 3160 3180 3200 3220 3240 3260 3280 3300 3320 3340 3360 3380 3400 3420 3440 3460 3480 3500 3520 3540 3560 3580 3600 3620 3640 3660 3680 3700 3720 3740 3760 3780 3800 3820 3840 3860 3880 3900 3920 3940 3960 3980 4000 4020 4040 4060 4080 4100 4120 4140 4160 4180 4200 4220 4240 4260 4280 4300 4320 4340 4360 4380 4400 4420 4440 4460 4480 4500 4520 4540 4560 4580 4600 4620 4640 4660 4680 4700 4720 4740 4760 4780 4800 4820 4840 4860 4880 4900 4920 4940 4960 4980 5000 0 5000 Birth weight (g)
Figure 4: Relationship between gestation time and birth weight by sex. Curves represent fitted linear regressions by sex.
Question

Do you think there is graphical evidence of interaction with sex?

Answer

The fitted lines are not strictly parallel, but there is no strong evidence of any interaction.

Exercise

Determine if there is graphical evidence of hypertension effects on the relationship between gestation time and birth weight.

Code
plot(
    babies_cat,
    x = :Gestation,
    y = :bweight,
    color = :Hypertension,
    Geom.point, Geom.smooth(method = :lm),
    Guide.xlabel("Gestational weeks"),
    Guide.ylabel("Birth weight (g)")
)
Gestational weeks 30 35 40 30.0 30.5 31.0 31.5 32.0 32.5 33.0 33.5 34.0 34.5 35.0 35.5 36.0 36.5 37.0 37.5 38.0 38.5 39.0 39.5 40.0 29.95 30.00 30.05 30.10 30.15 30.20 30.25 30.30 30.35 30.40 30.45 30.50 30.55 30.60 30.65 30.70 30.75 30.80 30.85 30.90 30.95 31.00 31.05 31.10 31.15 31.20 31.25 31.30 31.35 31.40 31.45 31.50 31.55 31.60 31.65 31.70 31.75 31.80 31.85 31.90 31.95 32.00 32.05 32.10 32.15 32.20 32.25 32.30 32.35 32.40 32.45 32.50 32.55 32.60 32.65 32.70 32.75 32.80 32.85 32.90 32.95 33.00 33.05 33.10 33.15 33.20 33.25 33.30 33.35 33.40 33.45 33.50 33.55 33.60 33.65 33.70 33.75 33.80 33.85 33.90 33.95 34.00 34.05 34.10 34.15 34.20 34.25 34.30 34.35 34.40 34.45 34.50 34.55 34.60 34.65 34.70 34.75 34.80 34.85 34.90 34.95 35.00 35.05 35.10 35.15 35.20 35.25 35.30 35.35 35.40 35.45 35.50 35.55 35.60 35.65 35.70 35.75 35.80 35.85 35.90 35.95 36.00 36.05 36.10 36.15 36.20 36.25 36.30 36.35 36.40 36.45 36.50 36.55 36.60 36.65 36.70 36.75 36.80 36.85 36.90 36.95 37.00 37.05 37.10 37.15 37.20 37.25 37.30 37.35 37.40 37.45 37.50 37.55 37.60 37.65 37.70 37.75 37.80 37.85 37.90 37.95 38.00 38.05 38.10 38.15 38.20 38.25 38.30 38.35 38.40 38.45 38.50 38.55 38.60 38.65 38.70 38.75 38.80 38.85 38.90 38.95 39.00 39.05 39.10 39.15 39.20 39.25 39.30 39.35 39.40 39.45 39.50 39.55 39.60 39.65 39.70 39.75 39.80 39.85 39.90 39.95 40.00 30 40 No hypertension Hypertension Hypertension 37.97000122070312918.0 39.91999816894533178.0 38.53054.0 38.02999877929693187.0 38.45000076293952852.0 38.02999877929693349.0 39.43000030517583322.0 38.90999984741213542.0 39.65999984741213948.0 37.59000015258793237.0 38.25999832153323172.0 38.09000015258793152.0 38.09000015258792552.0 39.22000122070313095.0 39.54000091552733061.0 38.84999847412113455.0 39.52000045776372595.0 39.88000106811522843.0 39.70000076293952963.0 34.34000015258792417.0 39.79999923706052639.0 39.5600013732912878.0 31.70999908447271938.0 37.09999847412113565.0 38.47999954223633337.0 38.93000030517583122.0 39.02000045776373087.0 39.5600013732913770.0 39.86000061035163486.0 38.90000152587893757.0 36.09000015258792949.0 39.20000076293953102.0 38.753294.0 39.0600013732913419.0 39.18000030517584197.0 39.43000030517583042.0 35.97000122070312719.0 37.9399986267092944.0 38.97999954223633601.0 31.37000083923342098.0 39.9399986267093830.0 38.45000076293952399.0 39.90000152587893581.0 31.29000091552731324.0 39.43000030517583463.0 39.74000167846683179.0 37.86000061035162944.0 39.56999969482422353.0 36.36999893188483093.0 39.90000152587893457.0 38.86000061035163140.0 34.1899986267091874.0 38.68000030517582978.0 37.36000061035162362.0 38.66999816894532801.0 37.54000091552732697.0 39.59999847412113350.0 39.74000167846683516.0 36.27999877929693559.0 39.49000167846683134.0 39.38000106811523383.0 35.95000076293952407.0 39.90000152587893337.0 39.70000076293952797.0 34.0600013732912497.0 37.11000061035162622.0 39.77000045776373041.0 38.83000183105473404.0 39.63999938964843082.0 38.36000061035163704.0 37.90999984741214035.0 37.81999969482422969.0 37.95999908447273562.0 36.99000167846682732.0 38.25999832153323160.0 38.04999923706054226.0 39.753200.0 38.36000061035163257.0 39.95999908447273090.0 39.75999832153323207.0 39.56999969482424287.0 38.15000152587892863.0 39.49000167846683425.0 37.95999908447272943.0 37.65000152587893045.0 38.6899986267092924.0 37.27000045776373333.0 38.95000076293953102.0 36.4399986267092666.0 39.40000152587893193.0 38.752744.0 39.34999847412112769.0 38.77999877929693695.0 39.16999816894533282.0 32.52999877929691541.0 38.22999954223632784.0 38.88999938964843804.0 37.79000091552732694.0 36.22999954223632425.0 37.52999877929692890.0 33.22999954223632659.0 38.90999984741212914.0 38.97000122070313154.0 32.40999984741211431.0 39.13000106811524319.0 37.79000091552733683.0 38.29000091552733331.0 38.22999954223632905.0 39.04000091552732558.0 35.52606.0 38.54999923706053156.0 39.95999908447273249.0 39.63000106811523040.0 38.86999893188483392.0 38.06999969482422855.0 38.72000122070313192.0 36.24000167846682736.0 34.66999816894531325.0 39.22000122070312605.0 38.15999984741213075.0 35.40999984741212274.0 38.04000091552732804.0 39.61999893188483625.0 39.50999832153323004.0 39.75999832153323428.0 38.6899986267093767.0 38.77000045776372646.0 38.22999954223633092.0 39.49000167846683249.0 35.68000030517581801.0 37.84000015258792719.0 39.8100013732913727.0 35.27000045776371500.0 36.9399986267092297.0 38.90000152587893546.0 39.04000091552732989.0 39.65000152587893734.0 37.90000152587893591.0 38.5600013732913576.0 38.47999954223633813.0 37.43000030517582188.0 39.61000061035163379.0 37.33000183105472802.0 39.6899986267093291.0 37.83000183105473590.0 37.66999816894532446.0 39.65000152587893105.0 39.20999908447272974.0 38.99000167846682982.0 38.50999832153323323.0 37.41999816894532360.0 32.8100013732911618.0 39.84999847412113664.0 38.99000167846683197.0 39.84999847412113003.0 39.90999984741213096.0 37.45999908447272938.0 37.22000122070312090.0 37.49000167846683558.0 37.13000106811522622.0 37.54999923706052482.0 39.91999816894533723.0 38.65999984741213505.0 39.54000091552734205.0 38.02000045776373554.0 34.02000045776371570.0 38.25999832153322699.0 37.04999923706052991.0 38.4399986267092831.0 37.33000183105472590.0 37.45999908447272879.0 39.09000015258793269.0 37.74000167846682718.0 39.20000076293953254.0 38.54999923706052729.0 38.27000045776373078.0 39.53647.0 37.56999969482423099.0 39.11999893188483041.0 34.63999938964843009.0 39.52000045776373943.0 39.04999923706052913.0 38.753367.0 39.70000076293952768.0 39.4399986267093341.0 39.97999954223633138.0 38.18000030517583096.0 36.81999969482422545.0 38.34000015258793385.0 38.99000167846682951.0 39.9399986267093216.0 39.41999816894532837.0 39.84999847412113079.0 36.9399986267092404.0 34.13999938964842328.0 38.9399986267094122.0 32.63999938964841741.0 37.77999877929693571.0 37.59000015258792992.0 38.88000106811523134.0 39.13999938964843109.0 36.15999984741213188.0 35.61999893188482505.0 38.253296.0 39.79999923706053518.0 39.8100013732914340.0 38.91999816894533448.0 39.66999816894533005.0 33.66999816894531880.0 36.45000076293952698.0 38.36000061035163561.0 39.84000015258793184.0 37.9399986267092842.0 38.0600013732912252.0 39.02000045776372539.0 32.47000122070311402.0 39.77000045776373051.0 38.40999984741212257.0 36.40999984741213606.0 39.75999832153322127.0 39.93000030517582609.0 35.72999954223632545.0 37.97000122070312704.0 37.88999938964843260.0 38.59999847412113575.0 39.70999908447273582.0 37.74000167846681791.0 37.86000061035163001.0 38.58000183105473501.0 38.33000183105474057.0 37.38999938964842762.0 34.70000076293952751.0 36.84999847412111999.0 37.63000106811523261.0 37.22000122070312428.0 37.09999847412112740.0 37.16999816894533007.0 38.58000183105472338.0 38.6899986267093360.0 38.59999847412113471.0 39.34999847412113292.0 39.75999832153322922.0 39.52000045776372995.0 37.58000183105473461.0 39.88000106811522579.0 37.74000167846683676.0 39.59999847412113233.0 37.04000091552733178.0 37.65000152587892764.0 37.88000106811523552.0 36.91999816894532935.0 37.25999832153322959.0 37.40000152587893545.0 39.753727.0 38.63000106811522926.0 39.45000076293953261.0 39.63999938964842610.0 39.86000061035163467.0 37.84999847412111546.0 35.13999938964841663.0 39.83000183105474092.0 38.74000167846683932.0 37.95999908447272092.0 36.27000045776372487.0 36.54000091552733198.0 37.47000122070313605.0 39.11000061035162894.0 38.25999832153322911.0 39.09999847412113332.0 37.08000183105472830.0 37.70000076293953773.0 39.45999908447273138.0 39.49000167846683226.0 38.09000015258792796.0 39.00999832153323784.0 39.84999847412113576.0 39.97000122070313942.0 38.18000030517583259.0 39.86000061035163430.0 34.86999893188482671.0 36.36999893188482418.0 38.91999816894533064.0 37.33000183105472893.0 38.93000030517584071.0 39.00999832153324141.0 38.47999954223632507.0 38.13999938964843451.0 38.58000183105473341.0 38.36999893188482215.0 38.68000030517584512.0 38.27000045776373571.0 39.04000091552733190.0 34.66999816894532597.0 34.59000015258792696.0 37.74000167846683392.0 37.16999816894533189.0 39.56999969482423354.0 37.88999938964841946.0 38.27000045776372929.0 39.61999893188482921.0 38.20999908447273296.0 39.95000076293953303.0 36.34999847412112797.0 37.68000030517582213.0 36.47999954223632002.0 37.61999893188482849.0 38.90000152587892887.0 39.58000183105473465.0 38.4399986267093079.0 38.63999938964843774.0 38.4399986267092148.0 39.43000030517583542.0 39.1899986267093305.0 35.70000076293952581.0 39.58000183105473234.0 37.4399986267093184.0 39.04000091552733743.0 38.50999832153323120.0 37.86999893188483503.0 38.79999923706053007.0 39.34999847412113279.0 39.11999893188483566.0 39.47000122070313509.0 36.40000152587892391.0 38.50999832153322887.0 39.18000030517583942.0 39.70999908447274022.0 36.52999877929693164.0 39.38000106811523798.0 39.54999923706053585.0 38.72000122070313306.0 32.79999923706051203.0 39.27000045776372894.0 39.45000076293953283.0 38.99000167846683804.0 39.34999847412113351.0 38.95999908447273035.0 39.22999954223633662.0 38.97000122070312724.0 39.33000183105473405.0 38.88999938964843200.0 39.79999923706053751.0 38.15000152587892620.0 38.52000045776372974.0 h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? 0 1000 2000 3000 4000 5000 0 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 4200 4400 4600 4800 5000 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360 1380 1400 1420 1440 1460 1480 1500 1520 1540 1560 1580 1600 1620 1640 1660 1680 1700 1720 1740 1760 1780 1800 1820 1840 1860 1880 1900 1920 1940 1960 1980 2000 2020 2040 2060 2080 2100 2120 2140 2160 2180 2200 2220 2240 2260 2280 2300 2320 2340 2360 2380 2400 2420 2440 2460 2480 2500 2520 2540 2560 2580 2600 2620 2640 2660 2680 2700 2720 2740 2760 2780 2800 2820 2840 2860 2880 2900 2920 2940 2960 2980 3000 3020 3040 3060 3080 3100 3120 3140 3160 3180 3200 3220 3240 3260 3280 3300 3320 3340 3360 3380 3400 3420 3440 3460 3480 3500 3520 3540 3560 3580 3600 3620 3640 3660 3680 3700 3720 3740 3760 3780 3800 3820 3840 3860 3880 3900 3920 3940 3960 3980 4000 4020 4040 4060 4080 4100 4120 4140 4160 4180 4200 4220 4240 4260 4280 4300 4320 4340 4360 4380 4400 4420 4440 4460 4480 4500 4520 4540 4560 4580 4600 4620 4640 4660 4680 4700 4720 4740 4760 4780 4800 4820 4840 4860 4880 4900 4920 4940 4960 4980 5000 0 5000 Birth weight (g)
Figure 5: Relationship between gestation time and birth weight by hypertension status. Curves represent fitted linear regressions by maternal hypertension.

3 GLM Approach

3.1 Model simplification

We can start model simplification using ANOVA.

model_1 = lm(
    @formula(bweight ~ Gestation + Age + Hypertension + Sex),
    births2
)

aov.anova(model_1; type=3)
Analysis of Variance

Type 3 test / F test

bweight ~ 1 + Gestation + Age + Hypertension + Sex

Table:
───────────────────────────────────────────────────────────────
              DOF       Exp.SS  Mean Square   F value  Pr(>|F|)
───────────────────────────────────────────────────────────────
(Intercept)     1  21680318.92  21680318.92  113.3498    <1e-23
Gestation       1  91012707.58  91012707.58  475.8360    <1e-73
Age             1     24612.93     24612.93    0.1287    0.7200
Hypertension    1   1519231.86   1519231.86    7.9429    0.0050
Sex             1   4734298.72   4734298.72   24.7520    <1e-06
(Residuals)   485  92765500.86    191269.07              
───────────────────────────────────────────────────────────────

Let’s remove Age from the model and define our contrasts for the categorical variables.

bw_cont = Dict(
    :Hypertension => EffectsCoding(),
    :Sex => EffectsCoding()
);
model_2 = lm(
    @formula(bweight ~ Gestation + Hypertension + Sex),
    births2,
    contrasts = bw_cont
)

aov.anova(model_2; type=3)
Analysis of Variance

Type 3 test / F test

bweight ~ 1 + Gestation + Hypertension + Sex

Table:
───────────────────────────────────────────────────────────────
              DOF       Exp.SS  Mean Square   F value  Pr(>|F|)
───────────────────────────────────────────────────────────────
(Intercept)     1  31652620.83  31652620.83  165.7846    <1e-32
Gestation       1  90992572.27  90992572.27  476.5851    <1e-73
Hypertension    1   1500405.49   1500405.49    7.8586    0.0053
Sex             1   4714027.66   4714027.66   24.6903    <1e-06
(Residuals)   486  92790113.78    190926.16              
───────────────────────────────────────────────────────────────
glm_coef(model_2 |> coeftable |> DataFrame, ratio=false)
4×5 DataFrame
Row Name Coef. Lower 95% Upper 95% Pr(>|t|)
String Float64 Float64 Float64 Float64
1 (Intercept) -4319.76 -4978.97 -3660.56 0.0
2 Gestation 191.005 173.814 208.196 0.0
3 Hypertension: Hypertension -80.664 -137.202 -24.126 0.005
4 Sex: Female -98.382 -137.285 -59.479 0.0

4 MLJ Continuous variables

4.1 Response and predictors

Our first model will contain all relevant predictors with no interaction terms. We can use unpack to define response and explanatory variables.

@select!(babies, :bweight, :Gestation, :Hypertension, :Sex)
babies |> head
5×4 DataFrame
Row bweight Gestation Hypertension Sex
Float64 Float64 Float64 Float64
1 2974.0 38.52 0.0 2.0
2 2620.0 38.15 0.0 2.0
3 3751.0 39.8 0.0 1.0
4 3200.0 38.89 1.0 1.0
5 3405.0 39.33 0.0 1.0
y1, x1 = unpack(babies, ==(:bweight))
x1 |> head
5×3 DataFrame
Row Gestation Hypertension Sex
Float64 Float64 Float64
1 38.52 0.0 2.0
2 38.15 0.0 2.0
3 39.8 0.0 1.0
4 38.89 1.0 1.0
5 39.33 0.0 1.0

4.2 Data splitting

We will split the data, in particular, the outcome (response) in two:

  • train : 70 % of the data
  • test : 30 % of the data
using StableRNGs
rng = StableRNG(566)
train, test = partition(eachindex(y1), 0.7, shuffle=true, rng=rng);

4.3 Model

LinearRegressor = @load LinearRegressor pkg=GLM verbosity=0
glm = LinearRegressor()
LinearRegressor(
  fit_intercept = true, 
  dropcollinear = false, 
  offsetcol = nothing, 
  report_keys = [:deviance, :dof_residual, :stderror, :vcov, :coef_table])
bw_mach = machine(glm, x1, y1)
fit!(bw_mach, rows=train);
glm_coef(report(bw_mach).coef_table |> DataFrame, ratio=false)
4×5 DataFrame
Row Name Coef. Lower 95% Upper 95% Pr(>|t|)
String Float64 Float64 Float64 Float64
1 Gestation 201.745 168.36 235.131 0.0
2 Hypertension -164.132 -320.005 -8.26 0.039
3 Sex -177.601 -292.207 -62.996 0.003
4 (Intercept) -4374.53 -5669.29 -3079.76 0.0

5 MLJ Categorical variables

In the previous section, we used a continuous version for all predictors. Let’s see what happens when we work with the categorical, original versions of the predictors.

5.1 One Hot Encoding (OHE)

One hot encoding is a process of converting categorical variables to form multiple numerical columns as there are categories. This is done so that the variables can be fed into ML algorithms to do a better job in prediction.

As before, first, we unpack data into response (outcome) and explanatory (exposure/predictor) variables.

@select!(babies_cat, :bweight, :Gestation, :Hypertension, :Sex)
y2, x2 = unpack(babies_cat, ==(:bweight))
x2 |> head
5×3 DataFrame
Row Gestation Hypertension Sex
Float64 Cat… Cat…
1 38.52 No hypertension Female
2 38.15 No hypertension Female
3 39.8 No hypertension Male
4 38.89 Hypertension Male
5 39.33 No hypertension Male
babies_cat |> schema
┌──────────────┬───────────────┬──────────────────────────────────┐
│ names        │ scitypes      │ types                            │
├──────────────┼───────────────┼──────────────────────────────────┤
│ bweight      │ Continuous    │ Float64                          │
│ Gestation    │ Continuous    │ Float64                          │
│ Hypertension │ Multiclass{2} │ CategoricalValue{String, UInt32} │
│ Sex          │ Multiclass{2} │ CategoricalValue{String, UInt32} │
└──────────────┴───────────────┴──────────────────────────────────┘

5.2 Model

In OneHotEncoder, all categorical variables are included by default (features argument). We want to drop one of the levels to use as a reference, we achieve this with the argument drop_last=true. We are going to include the OneHotEncoder as part of a pipe line.

ContinuousEncoder converts all categorical variables to continuous ones, creating new variables for the levels and makes sure that all numerical variables are indeed continuous ones. Instead of centring, we will use a scaler, one that standardises numerical variables.

pipe =  ContinuousEncoder(drop_last=true) |> Standardizer()  |> glm
ProbabilisticPipeline(
  continuous_encoder = ContinuousEncoder(
        drop_last = true, 
        one_hot_ordered_factors = false), 
  standardizer = Standardizer(
        features = Symbol[], 
        ignore = false, 
        ordered_factor = false, 
        count = false), 
  linear_regressor = LinearRegressor(
        fit_intercept = true, 
        dropcollinear = false, 
        offsetcol = nothing, 
        report_keys = [:deviance, :dof_residual, :stderror, :vcov, :coef_table]), 
  cache = true)
Warning

As we dropped the last level, we need to change the levels of categorical predictors so now exposed ones become the reference and their coefficients are shown in the coefficient table.

levels!(x2.Hypertension, ["Hypertension", "No hypertension"])
levels!(x2.Sex, ["Female", "Male"]);
mach = machine(pipe, x2, y2)
untrained Machine; does not cache data
  model: ProbabilisticPipeline(continuous_encoder = ContinuousEncoder(drop_last = true, …), …)
  args: 
    1:  Source @211 ⏎ Table{Union{AbstractVector{ScientificTypesBase.Continuous}, AbstractVector{Multiclass{2}}}}
    2:  Source @314 ⏎ AbstractVector{ScientificTypesBase.Continuous}
fit!(mach, rows=train)
glm_coef(
  report(mach).linear_regressor.coef_table |> DataFrame,
  ratio=false
)
4×5 DataFrame
Row Name Coef. Lower 95% Upper 95% Pr(>|t|)
String Float64 Float64 Float64 Float64
1 Gestation 347.848 290.285 405.412 0.0
2 Hypertension__Hypertension -60.574 -118.1 -3.048 0.039
3 Sex__Female -88.856 -146.195 -31.517 0.003
4 (Intercept) 3023.65 2966.53 3080.77 0.0

We can compare the coefficients against those from the GLM approach:

glm_coef(model_2 |> coeftable |> DataFrame, ratio=false)
4×5 DataFrame
Row Name Coef. Lower 95% Upper 95% Pr(>|t|)
String Float64 Float64 Float64 Float64
1 (Intercept) -4319.76 -4978.97 -3660.56 0.0
2 Gestation 191.005 173.814 208.196 0.0
3 Hypertension: Hypertension -80.664 -137.202 -24.126 0.005
4 Sex: Female -98.382 -137.285 -59.479 0.0
Note

The difference in the coefficients between the GLM model (model_2) and the MLJ model (mach), is that in the former, Gestation is centred, while in the latter is standardized (centred and scaled).

6 Diagnostics

6.1 Normality

bw_perf = model_perf(model_2);
resid_plot(bw_perf)
Theoretical quantiles -2000 -1000 0 1000 2000 -2000 -1800 -1600 -1400 -1200 -1000 -800 -600 -400 -200 0 200 400 600 800 1000 1200 1400 1600 1800 2000 -2000 -1980 -1960 -1940 -1920 -1900 -1880 -1860 -1840 -1820 -1800 -1780 -1760 -1740 -1720 -1700 -1680 -1660 -1640 -1620 -1600 -1580 -1560 -1540 -1520 -1500 -1480 -1460 -1440 -1420 -1400 -1380 -1360 -1340 -1320 -1300 -1280 -1260 -1240 -1220 -1200 -1180 -1160 -1140 -1120 -1100 -1080 -1060 -1040 -1020 -1000 -980 -960 -940 -920 -900 -880 -860 -840 -820 -800 -780 -760 -740 -720 -700 -680 -660 -640 -620 -600 -580 -560 -540 -520 -500 -480 -460 -440 -420 -400 -380 -360 -340 -320 -300 -280 -260 -240 -220 -200 -180 -160 -140 -120 -100 -80 -60 -40 -20 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360 1380 1400 1420 1440 1460 1480 1500 1520 1540 1560 1580 1600 1620 1640 1660 1680 1700 1720 1740 1760 1780 1800 1820 1840 1860 1880 1900 1920 1940 1960 1980 2000 -2000 0 2000 1342.14422088993111198.2025248468801 1192.84953701073621115.3327902416975 1117.86445356852441069.8660069278899 1066.15042236470321018.2879187896098 1026.1721684415766990.8359466161235 993.3416340889379982.9579821342049 965.3480665636854973.635517666165 940.8577393016749964.457454066444 919.028374202493960.6279070552314 899.2927801055995952.4076869618455 881.2501244280719912.3910380667414 864.6062688675019876.6627399368479 849.1387440533667875.3895177258289 834.675058049954872.0312318148806 821.0786645657739862.3581306584921 808.2395516117624843.1249904707745 796.0677332717219827.9910306540879 784.488629729467818.1511863938752 773.4397125106693803.6287758255775 762.8680196531064794.7468769624073 752.7282827259767792.854277729769 742.9814928977938784.7791493612093 733.5937877356648775.3426989007854 724.5355760894196756.609183033552 715.7808422849679733.4745875071046 707.3065871438284724.1438896025128 699.092374666123714.1767564007557 691.1199612087486713.5631834564506 683.3729897203845711.9429060253196 675.8367357582752701.2893895398809 668.4978950747947688.335424677686 661.3444048416836680.5977844635562 654.3652922950918671.9699624641348 647.5505458879637667.7951506587466 640.8910050359838656.0671745475825 634.3782653167117644.9925651950034 628.0045965848201637.7504181117159 621.7628719404669626.7341061756581 615.6465058631926623.1058896365203 609.6494001228587620.06346448784 603.7658963190867619.1470897731367 597.9907340942724616.6528232340777 592.3190142223546611.4285719495982 586.7461659037539607.1432133414014 581.2679177020099598.7353728911567 575.8802716443379588.539727896987 570.5794800800437585.5437880418042 565.3620249504411580.1976554907187 560.2245991737328572.380298898604 555.1640898901235560.785939645709 550.1775633476115550.5937070103719 545.2622512386257540.7958479020444 540.4155383228932536.9946498371104 535.6349511933544533.9047354098554 530.9181480602555528.2984607044502 526.2629094442144519.3968949682464 521.667129682524515.894595639345 517.1288091645414510.3950156260337 512.6460472220298505.842503834161 508.21703560899624502.40271099638005 503.8400525130777497.8729204469204 499.51345704711287496.7304073100121 495.23568417522074494.4642700896058 491.0052400327379491.15161786334716 486.82069760372855487.50718916505105 482.6806927236405483.15094483052883 478.58392037807175477.5000750828757 474.52913127159576474.60727597633513 470.51512864324076470.5432624830613 466.5407653075545461.89206797589566 462.60494090226564456.00519515494324 458.7065993253921453.1192605963841 454.8447263462959450.813601426452 451.01834737664245442.3113184339928 447.2265253885321431.2620525593943 443.46835896824643427.97371003069907 439.74298049509355422.45501209916847 436.0495544357846412.7529239571171 432.38727574561403408.69435482435154 428.7553683684819405.37674858198983 425.1530838284794404.12804582918795 421.57969990638236401.0899894850969 418.0345193949505394.6146275900147 414.51686892744357381.9218907823862 411.02609787422057375.28146177751444 407.56157730270365370.0611579904602 404.1226989963716358.5781077715164 400.7088745287821354.8353970013214 397.31953438894726353.6074668259552 393.95412715465756350.02405344099765 390.61211871062545346.09730538426595 387.2929915085418344.2116119948509 383.9962438663666342.31811650077157 380.72138930436984340.3275638930876 377.4679559156198334.55533962992985 374.2354857687855324.71576055253223 371.023534341271324.48538564866976 367.83166998083925322.77627525732464 364.6594733940177319.28052824085296 361.5065371596891317.0098611559389 358.37246526638927312.7715304822606 355.25687267192495312.1991835810628 352.1593848840298310.52174309643976 349.0796375608493308.9362072815692 346.01727613013963307.51336230013294 342.97195542612445307.2995198165097 339.9433393430341306.25126854056856 336.93110050440737304.14221992104666 333.9349199472956302.15752805652863 330.95448682056775300.390642605094 327.9894980965575294.5280247585089 325.0396582953488288.5423605663039 322.10467922103226282.6551911072908 319.1842797093119274.5948530462521 316.2781853858729272.06530169558204 313.38612843496156270.05319500658766 310.5078473776591269.64880651221904 307.64308685936269.02218754210344 304.7915974459972266.58167869973425 301.95313542858025263.8379124732022 299.12746263563946263.21623684486576 296.31434625318906261.20553532116156 293.5135586518502257.2634543835587 290.72487722078677247.62515612253725 287.948084208133247.11038385379538 285.18296656760657246.38990522243935 282.4293158110162244.39290090416392 279.68692786639286242.31958274564045 276.9556029414844239.81203354670387 274.2351453923675238.89849836697127 271.5253635969456238.04947706583624 268.826069833116235.35578261757266 266.13708016139054234.3312203718919 263.4582143117804232.64915802595422 260.78929557475055230.05998086646636 258.1301506960703230.00047871052175 255.48060977538898228.98116429147336 252.8405061683775225.87804092490205 250.20967639228058225.72645441363025 247.587960034738225.3872568211969 244.9751996657352224.1594728770431 242.37124075255159220.18701765066137 239.77593157758344218.1142841485835 237.18912315892055215.79876886643999 234.61066917356467215.23393284021785 232.04042588318262213.06290509350794 229.47825206228873210.40076732940278 226.92400892876182207.30647927535654 224.3775600766001200.7014190901379 221.83877141082857198.59039691597727 219.30751108446975198.0530170551771 216.7836494375197.55807302344164 214.26705893771182196.1657691681285 211.75761412340816194.9621241162249 209.2551915478601192.9944911185183 206.75966972545748192.0158478133059 204.27092907948864191.12490602075303 201.78885189148875190.29199499015505 199.31332225209525186.75982973677623 196.8442260133567185.8562018577223 194.38145074243698183.3590906689011 191.92488567666683175.39029240564054 189.4744216798893174.8936822057147 187.02995120005514173.31845762472489 184.59136822801935172.2803608666145 182.15856825749623171.41728686727095 179.73144824613158170.2470773274965 177.30990657765003164.4490275848028 174.8938430250417157.52408446920353 172.48315871474682154.00332632097536 170.0777560918073152.69530020266612 167.6775388859467150.4572270184692 165.28241207854964145.14874059323333 162.89228187050597144.02222856130697 160.5070556508907140.6917829250851 158.12664196645062139.8616585163161 155.750950491868138.34915523942644 153.37989200077755137.29353223842134 151.0133783375064133.23746957052538 148.6513223895153131.91476338577357 146.293638060515130.53774865633258 143.94024024423683128.84006021935795 141.5910447988318128.0579049695388 139.24596852187977127.22350205997911 136.904929125986125.88788621765347 134.56784521494524123.7288421739177 132.23463626045591123.29978226786105 129.9052225793623120.29484483017252 127.57952531140985118.79773042154615 125.25746639749411114.62298699100343 122.93896855838852107.13729402185432 120.62395527393245106.89259417899173 118.31235076266542105.38891143275372 116.00407996189239102.38990250332287 113.69906850816392100.60256254608993 111.39724271815957100.42172132072369 109.098529569958100.21758166259012 106.8028566846824599.68982748438708 104.5101523085076898.40074076820457 102.2203452950172592.04833278486012 99.9333650878970991.90418402821365 97.6491417039552891.56272748886656 95.3676057164560890.47731710200733 93.088688238756789.66537878940792 90.8123209082378188.66182671708009 88.5384358705152285.33064345992625 86.2669657639241585.22837532228566 83.9978437042654884.8400883532108 81.7310032698055782.01988188469615 79.4663784865190373.75862869878264 77.2039038135662872.27110489787846 74.9435141289968770.43985032309074 72.6851447156697867.50103084209573 70.4287312473835866.43023810919384 68.1742097752064566.03626701032655 65.9215167139994863.80887448308703 63.6705888291255963.1743525543254 61.4213632233349360.392546144869776 59.17377732382243558.171039637159765 56.9277688694468457.81638027616561 54.6832758981068156.63545621038475 52.44023673426518454.74831962620459 50.1985899766173849.943290046897445 47.9582744858939547.92037563893301 45.7192293727934145.720602597877516 43.4813939860379645.11804901268892 41.2447079005454942.79480375835309 39.0091109057132340.502880212785186 36.7745429938050437.74332125603258 34.5409443484379936.27295367953105 32.30825533316108534.71849113330968 30.076416480122333.449501789327364 27.84536847881587531.82641354495341 25.6150521649059929.87799396192261 23.385408509120827.436560912256112 21.15637860621067625.452396635324405 18.92790366396717523.744960635580256 16.69992499229477222.89911290209328 14.47238399233223820.653143348642224 12.24522214561680217.2946772172345 10.01838100328778813.23026524359021 7.7918021753222969.831553920869023 5.56542731979940359.263177087563996 3.3391981321872918.27599775272731 1.11305633464751045.425459700667227 -1.1130563346468594.888695284078301 -3.3391981321865794.870034224700095 -5.565427319798812-0.1338501016840065 -7.791802175321644-5.273930814621813 -10.018381003287137-8.76799645726194 -12.245222145616152-13.302973450861701 -14.472383992331528-23.245661801581072 -16.69992499229418-23.920191607501646 -18.92790366396652-26.969483386062294 -21.156378606210023-29.403121799513272 -23.385408509120087-31.1878830320379 -25.6150521649054-34.48027335467895 -27.84536847881522-34.727663325726084 -30.076416480121647-39.625968999833454 -32.30825533316043-40.77312096688856 -34.54094434843728-42.147733501268156 -36.774542993804445-42.719863151872445 -39.009110905712575-43.08419912714565 -41.24470790054484-43.2693697204841 -43.48139398603725-45.879166326267004 -45.7192293727928-46.025666893556235 -47.958274485893355-46.07206928424262 -50.198589976616724-48.426350113694106 -52.44023673426453-48.93745557303315 -54.68327589810609-52.39316687078854 -56.92776886944623-58.612912112772904 -59.17377732382178-59.342894235288945 -61.421363223334275-59.620604366390005 -63.67058882912488-62.79756353990162 -65.92151671399888-63.170262307225784 -68.17420977520584-66.22891215261713 -70.42873124738293-66.51579866118232 -72.68514471566913-69.86833681845357 -74.94351412899614-72.41841577207282 -77.20390381356569-73.95036393542912 -79.46637848651838-75.12958564181265 -81.73100326980492-78.78737705421082 -83.99784370426475-83.0000895117894 -86.26696576392344-83.45386636996922 -88.53843587051462-87.77575542726171 -90.81232090823715-92.30137474489054 -93.08868823875605-96.77831366236121 -95.36760571645537-100.17881775505792 -97.6491417039547-102.29486217871676 -99.93336508789643-102.66119825619278 -102.2203452950166-103.21191838639734 -104.51015230850703-103.3241919515608 -106.80285668468176-105.52408205386413 -109.09852956995742-109.0700829995808 -111.39724271815892-109.5510460243206 -113.69906850816326-110.57375677404816 -116.00407996189166-110.86752716704237 -118.3123507626648-114.85434230950092 -120.6239552739318-116.82228490146358 -122.93896855838787-119.41968315308708 -125.25746639749346-122.4991235997498 -127.57952531140913-123.34733552779622 -129.90522257936175-124.3536062234358 -132.2346362604553-130.10087444461942 -134.5678452149446-134.78430278790003 -136.9049291259853-137.40388724425242 -139.24596852187926-141.22672296448116 -141.59104479883118-141.8745566480836 -143.9402402442362-143.18639814211278 -146.29363806051438-144.36824165952345 -148.6513223895146-150.86280718564225 -151.01337833750583-151.9375733072107 -153.37989200077692-152.3376974961526 -155.75095049186737-152.83925057604546 -158.12664196644988-153.044554745516 -160.5070556508902-153.4386752453227 -162.89228187050534-153.69969959199813 -165.28241207854902-153.95084835853885 -167.67753888594606-154.55679489324214 -170.07775609180663-154.88668034631095 -172.4831587147463-155.7658088566484 -174.89384302504106-157.35940958710285 -177.3099065776494-157.64396076755287 -179.73144824613087-157.8257408769438 -182.1585682574957-157.87441342697852 -184.59136822801878-160.39864692714013 -187.0299512000545-161.10783800993931 -189.47442167988868-163.46505006053502 -191.92488567666615-164.11007707101484 -194.38145074243644-169.93723578832495 -196.84422601335606-172.76172438596134 -199.31332225209462-173.49530413203084 -201.78885189148806-173.7167283210593 -204.2709290794881-177.0846729562059 -206.759669725457-180.02621824827744 -209.25519154785948-180.6142229795376 -211.75761412340754-181.82732608176525 -214.2670589377111-185.74571665710064 -216.78364943749952-188.9649031563097 -219.30751108446913-189.97002585505163 -221.83877141082795-193.02533255301967 -224.3775600765994-203.66790573546004 -226.92400892876114-207.3174455472759 -229.47825206228816-207.75043260546744 -232.040425883182-210.32677251885997 -234.61066917356405-213.10388636416548 -237.1891231589198-215.53944276228088 -239.7759315775829-223.3567007974354 -242.37124075255096-225.58811215884484 -244.97519966573458-226.56021012038104 -247.58796003473728-227.33309107340494 -250.20967639227996-228.82057182547916 -252.84050616837692-234.65487711990866 -255.48060977538836-238.06846763909954 -258.1301506960696-243.31809840643712 -260.7892955747498-246.1948335368708 -263.4582143117798-246.86429416229444 -266.13708016138986-247.5062582724321 -268.8260698331153-248.10397788708596 -271.52536359694494-250.91090057291578 -274.2351453923667-252.8232024839256 -276.95560294148385-256.9623132972823 -279.6869278663922-261.1643893402927 -282.4293158110155-262.99303855654506 -285.1829665676059-263.8426703727994 -287.94808420813246-265.3891806247202 -290.7248772207861-267.51295443244766 -293.5135586518495-268.9774280984958 -296.3143462531884-270.84025600084647 -299.12746263563866-277.9244957244606 -301.95313542857957-282.2228816457967 -304.7915974459965-283.0719553601 -307.6430868593593-285.7075761101858 -310.50784737765844-289.40392132531156 -313.3861284349609-297.7181912561996 -316.27818538587223-308.44925575764444 -319.1842797093112-311.6915964950222 -322.1046792210316-312.6068059890949 -325.03965829534803-317.2733578230793 -327.9894980965568-319.4434153687481 -330.95448682056707-320.7046252310212 -333.93491994729493-321.3895231729175 -336.9311005044067-323.7037142050364 -339.9433393430335-325.717376513922 -342.97195542612377-326.8459789086597 -346.01727613013895-327.6613403085347 -349.0796375608486-328.8867618764013 -352.15938488402907-329.338091735866 -355.25687267192427-329.5978169244155 -358.3724652663886-333.34692211721483 -361.50653715968843-338.9504775588782 -364.659473394017-343.0461557747994 -367.8316699808387-344.4257421268359 -371.0235343412703-346.3258010677092 -374.2354857687848-348.2528671038779 -377.46795591561914-350.0484389135657 -380.72138930436904-352.0920858650314 -383.99624386636594-354.2531748718851 -387.2929915085411-355.3659558696024 -390.61211871062477-370.7118369009169 -393.9541271546569-378.69061093213656 -397.3195343889464-380.6601331639947 -400.7088745287814-381.78228068046724 -404.1226989963709-384.62865111584796 -407.561577302703-387.03644613868687 -411.02609787421983-389.03531152799 -414.51686892744294-391.1399117327187 -418.0345193949498-396.9530799735436 -421.5796999063817-400.6087133634293 -425.1530838284787-401.61265874587104 -428.75536836848113-401.87002789274266 -432.38727574561335-402.2080621813567 -436.04955443578393-404.1180850856068 -439.74298049509287-411.27279850497086 -443.46835896824575-414.61869043666417 -447.2265253885314-418.3295895489887 -451.01834737664177-420.31284957376783 -454.8447263462952-420.5821304478739 -458.70659932539144-420.8120387960804 -462.60494090226496-421.1047685576882 -466.54076530755384-421.71945749833253 -470.5151286432401-426.58718609105006 -474.5291312715951-430.6245728741113 -478.58392037807107-434.0137204282676 -482.6806927236398-436.31440467314565 -486.82069760372787-437.9500669553445 -491.0052400327372-444.7872645202522 -495.23568417522006-449.35975338350653 -499.513457047112-451.3372414035887 -503.8400525130772-455.32060127791306 -508.21703560899556-460.4666811249143 -512.6460472220291-465.29759671710826 -517.1288091645404-467.52967996514735 -521.6671296825234-469.1821774752062 -526.2629094442137-475.6394440300863 -530.9181480602548-479.4338250415976 -535.6349511933537-482.17277885536373 -540.4155383228925-484.8148127031921 -545.262251238625-486.71144299094067 -550.1775633476108-491.1438555028724 -555.1640898901228-495.3354597878142 -560.2245991737321-497.90221902434365 -565.3620249504405-503.04219766071583 -570.579480080043-512.3371173378931 -575.8802716443372-521.4699153139336 -581.2679177020092-531.4380725530577 -586.7461659037532-539.880010786713 -592.319014222354-562.4794278872575 -597.9907340942717-588.3733557078716 -603.765896319086-601.0246565509267 -609.649400122858-606.1488786778805 -615.6465058631919-608.1083796304079 -621.7628719404662-611.1331559115242 -628.0045965848194-614.7902565761653 -634.378265316711-618.150447587154 -640.891005035983-626.1709193954918 -647.5505458879634-632.2738078002642 -654.3652922950911-648.2392477989932 -661.344404841683-667.8850682649675 -668.497895074794-675.5246231659908 -675.8367357582742-678.3937363159712 -683.3729897203839-680.013948016097 -691.1199612087479-680.2647868076059 -699.0923746661223-681.2722025259528 -707.3065871438275-692.3836454711807 -715.7808422849677-709.7936831320208 -724.5355760894189-721.1222647668927 -733.5937877356641-731.5401698148191 -742.9814928977931-741.8414373381196 -752.7282827259759-746.2382304990606 -762.8680196531059-752.6162561886284 -773.4397125106686-767.6592791152473 -784.4886297294663-796.9172460252242 -796.067733271721-817.8557590084258 -808.239551611762-820.6604708720201 -821.0786645657732-821.5435246179806 -834.6750580499533-840.4618172198182 -849.1387440533658-862.4408947259647 -864.606268867501-869.2220725815439 -881.250124428072-880.9021763597115 -899.2927801055994-906.3487477277481 -919.0283742024918-930.316513905617 -940.8577393016737-949.539129012318 -965.3480665636853-974.7849574478735 -993.3416340889376-1027.4389525867246 -1026.172168441576-1080.339315748627 -1066.1504223647025-1187.7082795270294 -1117.8644535685225-1301.976965069733 -1192.849537010737-1336.4049617940004 -1342.144220889932-1576.2111940699879 h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? -2000 -1000 0 1000 2000 -1900 -1800 -1700 -1600 -1500 -1400 -1300 -1200 -1100 -1000 -900 -800 -700 -600 -500 -400 -300 -200 -100 0 100 200 300 400 500 600 700 800 900 1000 1100 1200 -1810 -1800 -1790 -1780 -1770 -1760 -1750 -1740 -1730 -1720 -1710 -1700 -1690 -1680 -1670 -1660 -1650 -1640 -1630 -1620 -1610 -1600 -1590 -1580 -1570 -1560 -1550 -1540 -1530 -1520 -1510 -1500 -1490 -1480 -1470 -1460 -1450 -1440 -1430 -1420 -1410 -1400 -1390 -1380 -1370 -1360 -1350 -1340 -1330 -1320 -1310 -1300 -1290 -1280 -1270 -1260 -1250 -1240 -1230 -1220 -1210 -1200 -1190 -1180 -1170 -1160 -1150 -1140 -1130 -1120 -1110 -1100 -1090 -1080 -1070 -1060 -1050 -1040 -1030 -1020 -1010 -1000 -990 -980 -970 -960 -950 -940 -930 -920 -910 -900 -890 -880 -870 -860 -850 -840 -830 -820 -810 -800 -790 -780 -770 -760 -750 -740 -730 -720 -710 -700 -690 -680 -670 -660 -650 -640 -630 -620 -610 -600 -590 -580 -570 -560 -550 -540 -530 -520 -510 -500 -490 -480 -470 -460 -450 -440 -430 -420 -410 -400 -390 -380 -370 -360 -350 -340 -330 -320 -310 -300 -290 -280 -270 -260 -250 -240 -230 -220 -210 -200 -190 -180 -170 -160 -150 -140 -130 -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990 1000 1010 1020 1030 1040 1050 1060 1070 1080 1090 1100 1110 1120 1130 1140 1150 1160 1170 1180 1190 1200 -2000 0 2000 Residuals
Figure 6: QQ-Plot of the residuals from the GLM model predicting birth weight.

6.2 Homoscedasticity

rvf_plot(bw_perf)
Fitted values 0 1000 2000 3000 4000 0 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360 1380 1400 1420 1440 1460 1480 1500 1520 1540 1560 1580 1600 1620 1640 1660 1680 1700 1720 1740 1760 1780 1800 1820 1840 1860 1880 1900 1920 1940 1960 1980 2000 2020 2040 2060 2080 2100 2120 2140 2160 2180 2200 2220 2240 2260 2280 2300 2320 2340 2360 2380 2400 2420 2440 2460 2480 2500 2520 2540 2560 2580 2600 2620 2640 2660 2680 2700 2720 2740 2760 2780 2800 2820 2840 2860 2880 2900 2920 2940 2960 2980 3000 3020 3040 3060 3080 3100 3120 3140 3160 3180 3200 3220 3240 3260 3280 3300 3320 3340 3360 3380 3400 3420 3440 3460 3480 3500 3520 3540 3560 3580 3600 3620 3640 3660 3680 3700 3720 3740 3760 3780 3800 3820 3840 3860 3880 3900 3920 3940 3960 3980 4000 0 5000 3111.739159258524-0.4447551510551651 3287.4337511981107-0.25122037656673546 3016.2071679686620.08675869547090828 2961.8704589209360.5168161327467587 3006.6570695751757-0.35503678556213264 3692.393447917217-1.6629457802172143 3123.19898588040860.518357592381002 3193.84176686573570.29420502574047747 3094.51914059660931.0272544692561594 3237.77280237645251.630425184931471 3039.1570999415190.4541758580839407 3167.13002139112540.011179712351982875 3134.6595411280810.03980743198464543 3514.7595776459525-0.24278580082351944 2937.8951953407145-0.8858760229582782 2992.40238947809030.23552706608312118 3411.616766294262-0.8048894887976398 3279.82293113630250.4021432942212311 3211.0322354243503-1.414187565227359 3279.7941096587915-1.002721550794356 3442.1775183289474-1.100018552585173 2221.62688644149880.4485061201121413 3461.27771511592-1.8876527120037352 3218.67260558946-0.7820612866246376 1719.2838417849640.5020933215433762 3627.451758765320.20786606518907763 3556.78015630248232.2020223898542097 3583.5207232546030.06308249672683451 2945.56438698333481.4220004912303446 3012.3869828860980.7451942705517546 3295.10367146654-0.39738352249465253 3319.9049600869632.2499443023972003 3312.294140025155-0.5171939924908218 3415.43695137682650.8139487280346543 3472.73827036361260.030444142476191576 3092.60941236823151.5252008798463679 2752.64977638183250.450749211977759 3553.98603145309061.4416932979105241 3694.30390477140330.7958890437728885 3346.6750771423854-0.5616856257164123 3552.9311497424274-0.5668647537453729 3740.14466851049841.2944082347092116 3063.9583885619430.528092472557815 3319.9345101902640.22741859236567472 3342.85489205982141.9608087387126907 3193.8417668657357-0.3485738671382318 3147.115877879818-0.601723406391145 3419.22758635608941.6385637207478454 2532.9650487249090.42706907149052614 3537.679959515511.5755429849396116 2909.2441715344260.07978683193637022 3459.3384367842420.2104218504405595 3451.698066619134-0.75686770802035 3259.8087876249950.289689456362241 3304.65376986002640.680303934707683 1851.1068627333290.5667774908272205 3533.8597744329454-0.36238903942889866 3291.25393628067471.2367664227866795 3006.6570695751757-1.3949612086837588 3480.3786405287220.2309903072889234 3677.1134362127887-1.4074870562068487 1477.733613969148-0.35291686494761465 3390.6061126531020.16619022414294565 3253.0535427066893-0.17000019355268634 2893.96415982999770.11486422124546403 3339.005156873956-0.26860158998764744 3682.8145280462186-1.1450980360334444 3220.5823338178366-1.9916557571876998 2448.0380375392171.4805997720693627 3480.378640528722-0.053668916700219275 3281.733387990488-0.3253686793445526 2031.6473356757378-0.36190135675331864 3369.5659089086220.40273332444606547 3561.5968515149193-1.1009811901602669 3050.5881050858925-0.1666360779402628 2995.226064430802-1.4536583879884766 3048.677648231705-0.5685784447184927 2671.51412880117460.05850635740439349 3625.54203053694350.5175700857219468 3389.7217160320874-0.9658251387183431 3226.3122471287790.283942417332924 3331.36551533463670.3802369666990627 3449.81788849405580.1519302298648783 2592.1760959400752.219478566643964 3402.0666679007745-0.6153842714676595 3184.2916684722290.4561625762328426 2725.9092094297316-0.7321003877359553 3480.378640528722-0.32914558507680897 3245.413172541581-1.0293947235660972 2364.9100983246430.30323071699765464 2786.1463168780483-0.37682067083210674 3327.54533025207230.9307775133324124 3371.4763657628080.13894040931420673 3585.4311801087906-0.15250200143912415 3455.547801804998-0.9516520610339979 3079.2391288921810.7455336899321751 3233.9526172938886-0.348828339693529 3186.2309468039261.1886107813579632 2903.51425822348532.597482687168404 2886.32378966486930.18979472480936574 2751.7358296575181.8600739512572366 3572.06089663272-1.3867056941746443 2763.2259350084914-0.0716834711923602 3005.8014944316530.3539840881884767 3127.01917096295262.522863144940569 3451.7276167224336-0.5778757099422933 3522.3992191852717-0.3498535763696032 2989.46660101655970.6141600785951913 3491.8384671506055-0.9224760179683714 3453.637344950812-0.5661902840358121 3417.3466796052031.9964099945416458 3411.587216190961-0.8897602918470252 3146.1200963757547-0.649941507500433 3402.06666790077450.05264664934557042 2913.06435661699060.0687214275405087 2853.8533094018260.4388037791432969 3087.9336521421633-0.37633246939108345 2978.03559587218750.8148700953450924 3102.159510761738-0.0003661791101160226 2819.501193762106-0.35238331207845364 3188.11185355479350.011221419143852326 3260.7227343493096-1.1862088111082458 3612.1717470608914-0.7487725516575514 3017.2324995760255-0.5698521830499733 3266.4526476602520.9837899738680188 3340.944435205634-0.13531513858156563 1714.5792600813863-0.39847530222078303 2964.6357622928167-0.4146744832174237 3090.69895551404531.6374816273711024 2880.5938763539284-0.4283521616454467 2582.625997546568-0.36185237211387666 3027.6965446938466-0.3161015448269094 2206.3756962145621.0390619602757147 3696.2136329997816-0.17266334196066196 3891.03870045544950.20422302010820415 3505.2087506266570.32320586928288364 3094.5191405966093-0.41440676191465997 3105.97969584428170.11023727836039758 1852.9874051713018-0.9687307039456031 3700.0338180823251.0995334004978048 3333.30479366631472.262800262296489 3394.39674763234640.09321040572912496 3680.933621295353-0.6495134280513972 3077.3582221412951.3903348266182551 3698.12408985394860.07317557940421407 3172.8606633278570.363030813381048 2964.6357622928167-0.1369021759376957 3154.7857981482275-1.3700046950694813 3342.82534195652-1.1106882773195534 2478.62833967718320.29239933859436773 3222.5216121495146-0.15270960074990025 3295.074121363239-0.10576954542936542 3267.478707893404-0.5222089714757208 3122.3145892593940.6191003205049521 2934.0750102581505-0.1815276698146671 3442.147968225627-0.5926145186248466 3254.9928210383673-0.14460877059410215 2423.20792744128180.7180576503590343 2284.658118739208-2.2030285110901904 3350.4952622249293-1.7113879260687976 3763.065779005844-2.442710797783921 2951.26547881676650.28404978048941365 2622.766398078041-0.8006417115353526 3125.1094427345756-0.7371513289065357 3426.89677799870970.45477346326319407 3405.8861243575307-0.9225854217066036 3256.87299916344550.3928458004977653 1555.0198906768371-1.4485938096917919 3052.49783331426941.640238970220331 3453.6085234733010.6551557761387558 3103.214392472401-1.0495991464343633 3000.07158112071060.21103445468328463 3402.0666679007745-0.3513857976067611 3566.3302546959885-0.2647566193889545 2477.57345796652-1.5531683509387137 3319.904960086963-0.7183167993605535 3512.84912079176552.387810823443875 3709.5839164758318-0.7910402440576605 2890.1439747474333-0.39288476646791837 3463.18817197010730.6056166955334381 3471.8538737425993-0.282028131964746 3424.9574996670126-0.11238874083597263 1527.42411289412620.15512983535432143 2596.025831125939-2.516079536777137 2718.239289161302-0.9670132997289874 3528.10031101870350.5185841142322941 3826.097011303573-0.09893517575747122 3092.60941236823151.0408210712841979 3316.1143251077-0.7509363704910493 3235.86307414807471.1435425060753717 3098.36887578247341.1309031736504838 3621.721845454379-0.27483812598057816 3526.189854164516-0.5422066177466127 3063.10354204422951.1774250621650766 2851.05845592662542.208270431119713 3008.5963479068537-1.883792900028142 3684.75380637789660.19569447842335544 3233.0682206728740.35107614214950367 3424.9870497703314-0.10556966049332828 3367.6561806802442-0.9519008597962915 2792.7318053324950.021276428240582703 3304.6242197567267-1.0069228227322022 3082.17418872792130.47938865633558864 3656.1027825716083-0.4731375657164282 3084.99859230642321.1593008776409528 3054.4371116459474-1.396751903607507 3235.8630741480747-0.30041436399858606 3841.3777516337921.3351946602802027 3151.820459583396-0.40821156479356663 3306.5642267142125-0.7450822654121289 3018.116896197040.6999015139996104 3640.8227708671798-1.5606276000419375 2809.9215452652998-1.0328574026710986 1929.3896495708711-0.7148381935894785 3470.82781350942650.4434535863120364 3306.5642267142125-0.2515199012374058 3470.8278135094265-1.0739637286623451 3285.524022969734-0.43507872020858834 1516.81876847706120.5674388512096796 378.42984440342531.1146937393903882 2817.5619154304280.2764823523573627 3409.6774879625840.08338337169279848 2807.1569705192082-1.6463334411806645 2823.29255736715961.6866229877331598 2951.295028920066-0.755942478998939 2834.752383989024-0.8097920958599658 3484.1980969854770.5482029387035846 3642.732499095558-1.4226820344628526 3243.5322657906950.6002355025662912 3688.5739914604610.012456156292125353 3411.6167662942621.821321416392515 3121.28925765203080.9933476139398283 1999.1768554126947-0.9852350856119214 3350.4657121216296-0.23063299717790148 3848.9885716956187-0.3535021558231562 2970.365675603759-0.6229576018923834 2936.0142885898280.12622733822992255 3004.746612720988-0.3988594834507959 3455.518251701678-0.33176172081989763 2989.496151119861-0.9170989061647504 3014.3262612177946-0.3106602298678186 1563.7147782397335-1.9988467184645249 3128.9000777138390.32161883192675567 2709.71525100096820.019018792104912252 3444.05842507981331.0902943561045284 3388.666834321424-0.5180495640163155 3346.6750771423854-0.2127485124393987 3222.5216121495146-1.132947412389932 3549.1109646598630.9799830768499761 2972.2761324579450.24270382331977555 3455.518251701678-1.7389883684436434 3403.9763961291530.5578944394267749 2838.5725690715880.5978473418836106 3331.3943368121477-0.6666405368369981 2475.69255121563361.2242813267627992 3211.03223542435031.6803336762029986 3490.95407052957172.169484200944759 3318.0240533360766-0.9297889735450385 3906.2898906823875-0.9648338236462106 3382.93619238467270.8839674569522864 2902.62986160247061.06602615516106 3442.1775183289474-1.5476681386971312 3195.75149509411270.3334381184846208 3298.894306445784-0.36935522917038927 2793.7571369398580.6938404746367475 2892.0832530791113-0.7967778183961863 2985.64641593399570.9167716236896092 3562.51079823923370.733431840694599 1044.1816293374784-0.14504220627077694 3306.5642267142125-0.8162470714094145 3326.6897551085685-0.2541037080060762 3191.9313100115482-0.8147941232043325 3470.8278135094265-0.8994951720238382 2556.9107622018296-0.35102789441904214 2183.4257642417050.33189023999822176 3677.0838861094876-1.230655024298474 3297.0133996949171.8938713342281115 1896.9184406820189-0.3579324381462964 3566.3302546959885-0.23720895255129554 3075.4477652871281.1376089885439646 721.3540903288842-0.030656169275009613 2681.064227194680.7137962564292476 3088.7892272856670.10378760868396321 3138.4501761073266-0.06760696997625211 2569.2557140705181.4204134538742132 2662.8772485062127-0.36242915359128736 3165.22029316274760.300222982756611 3461.277715115920.1302138838547843 3463.18817197010732.0128433431571837 3096.42886882498620.8070803659456808 3436.446876392196-0.9904462340834043 3591.1610934197130.4954881907565283 2093.653236366084-0.4904706811833745 3938.7899210487310.4412449348158069 2821.4116506162936-0.2833085862552696 3186.2309468039260.8603344182091938 3480.349090425422-0.6894930565027871 3272.1537394936818-0.20236915383881113 3310.35486169345770.49504336876912575 3493.7193739014724-1.8703014898686565 2944.67999036232-0.2357161804496029 2932.1652820297736-1.5614138819915468 3507.1192074808240.09843881550441898 3115.5297942377883-1.3235042244705566 1864.4479604189742-1.0616135286147341 3850.9278500272967-0.355658399702231 3535.7406811838114-0.8947038698611588 3258.7834560176316-0.4769957850625907 3195.7810451974137-2.155102288883969 2813.77128045116521.8186710687797045 3236.888405755438-0.2545597381591629 3453.637344950812-3.045480299425119 3289.3442080522977-1.5618246315296371 1053.7320920438606-0.07973234168326546 2487.1235563600060.13286341559525724 2914.9748134711576-0.4843219893867254 2899.6940731409210.8271323027289854 3381.026464156296-0.6061094225752293 3232.07171054302130.7872395222640934 3444.08724655732430.31659788204191885 3067.8081237478073-2.9310904007184204 2893.96415982999770.24571563872434413 3316.0847750043990.4290898620887394 3228.25225408626650.626130336262832 3180.50103349298522.01212512607397 2804.191631954359-0.0968567517013177 3505.2087506266570.7318295940414917 2487.15310646332640.6056971932749627 3604.531376895763-1.1191959953024697 2736.4846394305814-1.6929984287437265 2885.46894314715560.8620837034480098 3346.645527039065-0.7337907070850073 2807.1569705192082-0.8704074919199367 2748.8000411959683-0.020201716918684852 2762.1703246720190.5620405273256188 3669.4730660476603-0.2352411569428647 3228.2522540862665-2.04369770808695 3052.49783331426940.7059139366430643 3232.07171054302130.5484930763377156 3688.573991460461-0.120690900089893 3661.80387440504-0.09367096148297756 3375.3253723228645-0.19128496632284744 3497.539558984037-0.11142929994492928 3256.8729991634455-0.7687474844901878 3211.0322354243503-0.49593200397206 3514.7300275426514-1.2045906648717155 2840.48302592577561.424482905742416 3279.7941096587915-1.6087702212228536 3067.80812374780731.3961889316971756 3406.9121845907021.3270808784837855 3423.0765929161453-0.4363472212742756 3358.106082286739-0.16093824984404975 810.1009222842465-0.4180379614930716 2772.7760334019790.9302479022064101 3474.61917711448-0.476618660021551 3594.9812785022771.088175817886027 3050.6176551891926-0.6579706395785753 3094.54869069990951.0501430219208143 2714.41910407873770.5063740859659377 3638.91231401299360.5511546321162105 2618.03226627116240.7827387942628021 3359.16096399742130.1465513745863622 3002.86643459591141.2445429034386684 3451.72761672243360.6319259920115631 3237.8023524797527-0.7157856104425453 3197.66195194830.1454012871563211 3430.716963081255-1.8840697889148066 3275.9739245762460.4385268902565896 3604.531376895763-1.2454561349750735 3550.1658463705453-0.9209319235386059 2892.0537029758116-3.090053246264569 2409.8664654427234-1.7145357135196742 3467.00835705267171.4347551296861751 3321.81468831534130.6202479125598347 3656.10278257160830.7779856364939167 3258.81300612093131.5453942522354787 2751.735829657518-1.514515236355987 2590.2663677116966-0.23706229110475083 3463.1586218668062-0.6431430314070388 2641.8377733875231.2767476438675909 3016.2367180719621.3515878947333548 3331.3655153346367-0.8754775133175585 3503.26947229495860.20598889019881655 3329.4846085837694-0.999715409182834 2970.365675603759-0.13628215442707498 3130.8098059422170.46186003640897977 2744.98058473921360.19517387719472626 2898.83922662322632.006757478961138 3501.3597440665820.4904408827971651 3038.2431532172040.22900569832898718 3205.3023221134080.04751439456108391 2937.8951953407145-0.3257401305925459 3113.6193373836021.538951929013798 3274.063467722060.6931372497758954 3296.9845782174061.480722495368247 3151.8500096866970.24597768623410418 3696.1848115222706-1.038053044738761 3472.7382703636126-0.09811163609955027 2519.62358672636950.34750558332847853 3413.4976730451485-0.7380425655108643 2644.8023833265834-0.5206563744889788 3337.0954286455791.583771773454125 3510.93939256338850.2113379118780228 3293.1932146123527-0.5261448597994309 2792.7318053324950.23017956842616322 3295.103671466541.7811777965835442 3310.38368317096871.9067951304941277 3736.325212053742-0.9649149087604036 2851.0584559266254-0.7898339763788379 3591.161093419713-0.5811664548153097 3144.20963952156850.7042798866220933 3031.48790829890.7105279987007371 2991.376329244938-1.7822797048903491 3247.3524508732592.903174112533784 3169.04047824531150.9227539156269069 3119.34997932033370.16218693597976303 3570.150439778553-0.3699432188134842 2481.42246452657450.2653242867616358 2466.1424528221460.5276699274814161 3067.80812374780730.7442274832059135 2958.93467045938540.5281469207567552 3220.58233381783660.30627878485368576 2935.1298919688147-2.2706850602605435 3623.6027522052655-0.5477457603582634 2972.276132457945-0.0993463732478233 3426.8967779987097-1.161356324546132 3157.5799229976380.31776251374201375 3293.1643931348620.022579001755583316 2802.3107252034915-0.012191507381012654 2895.0190415406623-1.5656694444418056 2469.048691180377-1.0721751451334751 2883.5584862929886-0.07933380556775527 3675.2029793586010.48391384125003056 3499.478837315715-0.2857584615593726 3505.2087506266572.285977131466085 3289.373758155598-0.9237048528239318 3419.25713645939050.10500909708476662 2843.41808576151560.5408110072016422 3239.71208070813051.2265321330032029 3004.746612720988-1.966780854294219 3229.27758569362960.7178977401650201 3619.8121172260010.13357836738723883 3344.764620288198-0.09128520930210819 2678.1579888364504-0.22303965892362776 3257.928609499918-0.05493144686601572 3010.50607613523060.39827940108206905 3568.24071155017460.05454274687630161 3154.78579814822751.350327405149342 3053.5527150249340.15253897239667422 3092.63823384574240.9420424347442331 3430.6874129779535-0.8670339184578321 3270.272832742796-0.6043793569837717 3178.5610265354980.23057161487638006 3679.0231644411656-0.062035427577042584 3331.39433681214770.5385698873105816 3201.4821370308440.7059499696419302 3390.5765625498011.19470428911561 2811.8615522227874-0.9661461521177805 3214.8812419844066-0.7526969347086901 3146.0905462724551.8271207053524623 3247.3229007699581.7783788863627723 3585.4311801087906-4.1446180539965365 3619.7825671227010.2736801768453995 2675.36313536124951.1217337959722127 3184.2916684722291.4088527210352153 3413.5264945226390.39364125003131845 3329.4550584804506-1.114429517972976 3339.0051568739560.950382667578762 3058.2284752510010.5687939513036827 2124.2435385040503-2.1148425062546368 3163.2810148310696-0.6181719735227513 3197.66195194830.19590534302536255 3444.05842507981330.29600329561869476 3306.56422671421251.1419329129675104 3178.5610265354980.39585761590233387 3300.833584777481-0.6102579189758855 3155.6406446659411.1624182350728682 3509.028935709201-1.0790167104147088 3497.539558984037-1.1398755285508642 3105.9796958442817-0.8768874499890488 3675.2029793586010.7915294542705558 3371.50591586610970.07689032256274335 3690.4541695855390.6187798944781403 3539.58968774388630.5358257932087799 3711.464823226699-0.19160509524276792 3487.989460590530.42471739175897016 3126.1347743419390.16956788560972913 3461.277715115920.665097748285996 2949.355750588388-0.7560818740230023 3020.0273530512263-0.10566218227287479 h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? -5 -4 -3 -2 -1 0 1 2 3 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 -5.00 -4.95 -4.90 -4.85 -4.80 -4.75 -4.70 -4.65 -4.60 -4.55 -4.50 -4.45 -4.40 -4.35 -4.30 -4.25 -4.20 -4.15 -4.10 -4.05 -4.00 -3.95 -3.90 -3.85 -3.80 -3.75 -3.70 -3.65 -3.60 -3.55 -3.50 -3.45 -3.40 -3.35 -3.30 -3.25 -3.20 -3.15 -3.10 -3.05 -3.00 -2.95 -2.90 -2.85 -2.80 -2.75 -2.70 -2.65 -2.60 -2.55 -2.50 -2.45 -2.40 -2.35 -2.30 -2.25 -2.20 -2.15 -2.10 -2.05 -2.00 -1.95 -1.90 -1.85 -1.80 -1.75 -1.70 -1.65 -1.60 -1.55 -1.50 -1.45 -1.40 -1.35 -1.30 -1.25 -1.20 -1.15 -1.10 -1.05 -1.00 -0.95 -0.90 -0.85 -0.80 -0.75 -0.70 -0.65 -0.60 -0.55 -0.50 -0.45 -0.40 -0.35 -0.30 -0.25 -0.20 -0.15 -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 1.70 1.75 1.80 1.85 1.90 1.95 2.00 2.05 2.10 2.15 2.20 2.25 2.30 2.35 2.40 2.45 2.50 2.55 2.60 2.65 2.70 2.75 2.80 2.85 2.90 2.95 3.00 -5 0 5 Std residuals
Figure 7: Residuals vs Fitted plot.

6.3 Influential observations

cooks_plot(bw_perf)
Index 0 100 200 300 400 500 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 172 174 176 178 180 182 184 186 188 190 192 194 196 198 200 202 204 206 208 210 212 214 216 218 220 222 224 226 228 230 232 234 236 238 240 242 244 246 248 250 252 254 256 258 260 262 264 266 268 270 272 274 276 278 280 282 284 286 288 290 292 294 296 298 300 302 304 306 308 310 312 314 316 318 320 322 324 326 328 330 332 334 336 338 340 342 344 346 348 350 352 354 356 358 360 362 364 366 368 370 372 374 376 378 380 382 384 386 388 390 392 394 396 398 400 402 404 406 408 410 412 414 416 418 420 422 424 426 428 430 432 434 436 438 440 442 444 446 448 450 452 454 456 458 460 462 464 466 468 470 472 474 476 478 480 482 484 486 488 490 492 494 496 498 500 0 500 4900.00023662511890588226 4897.881040184924393e-5 4888.644460748465718e-6 4870.0010643104145528711 4860.00014525858895261232 4850.004162717829481287 4840.00031818070090998575 4830.00010108509341032247 4820.0011981011133397267 4810.0031892402677983086 4800.0002660414764800312 4791.430706253806959e-7 4781.8585122433396184e-6 4777.13806347542578e-5 4760.0009383259806951895 4750.00026083472070654424 4740.000726338793997241 4730.00017668803955867167 4720.0023580048099584488 4710.001247069403699668 4700.001381366958238154 4690.0006526017564487266 4680.004122649277227561 4670.0007244945853838828 4660.0016498603699317937 4655.950219461074403e-5 4640.006131882123001953 4635.188597963920474e-6 4620.0029400137954462536 4610.0006385895642018009 4600.00017227247336228164 4590.0065214137932582865 4580.0002917356924134019 4570.0007442845539438667 4561.0818323440332155e-6 4550.0026409385142668637 4540.0003960405812940194 4530.011072019803415229 4520.00095612886427354 4510.0003454621864191554 4500.000561016156226434 4490.0027055701201282533 4480.00031692554208390925 4475.642790973515522e-5 4460.004206913544524141 4450.0001418981036123633 4440.0018408431265151527 4430.0038817722213864056 4420.0003628498664581898 4410.0030755988553921453 4407.77582939622805e-6 4396.75301371683378e-5 4380.0008646236824932802 4370.0004576551935045808 4360.0005047290842107223 4350.002332923230727402 4340.00016207171943626375 4330.0019167092615322802 4320.0022424324891730193 4316.266409986001001e-5 4300.0029180137088542922 4290.0010594553372858197 4283.066083635880601e-5 4273.50658696994479e-5 4261.6322232254001984e-5 4259.481798477547418e-5 4240.002800057369717816 4230.004704407087511269 4220.009820240349285287 4213.3828048985241366e-6 4200.00011563455458454085 4190.0007189162389041117 4180.00022059733173164322 4170.008280038274786869 4163.16135801762791e-5 4150.002875274454005806 4140.00036818094180539486 4131.4927351134415662e-5 4120.00036798283858081155 4110.004426139908153967 4109.597235988877333e-5 4090.00018847394609815905 4082.648767510251428e-5 4070.008941776532167869 4060.0004225660989337255 4050.00024186490429274502 4040.001090585397704927 4030.0001272352245808718 4020.0012783441693206272 4010.0003313728669385025 4000.0005654967802591556 3990.0011248614000574158 3982.6314308317311937e-5 3973.03926059973845e-5 3960.0010434446212203847 3950.0006309916722744048 3940.00014559589676686597 3930.001597707193353765 3920.008279724448889844 3914.486273740677786e-5 3900.015187229377906678 3890.002473960398304343 3882.0530943723395385e-5 3870.0005028852492103339 3860.00751249480926151 3850.00038371009039566637 3840.0001493231613142968 3830.00043781876866406407 3820.0010091422922430425 3810.00036884589536825585 3800.004482233537546226 3790.0011334342733075704 3780.0004909544146328206 3773.09273949425335e-6 3765.751071212294259e-6 3750.0002473063400332687 3740.0005802317549531363 3730.000923900870371063 3721.5231226937846543e-10 3710.00021774088703639048 3701.466320617733652e-7 3690.0015427709756963743 3680.0007571138864011179 3670.001543682121430787 3660.0010598392463174856 3652.002799456644544e-5 3640.0011068997256421579 3630.0002021671579164067 3620.0030439086808294455 3610.00022970026030264082 3600.00024117680393425314 3590.00013061548423252953 3580.004908206992862532 3574.5123675757605094e-5 3568.535539091723279e-5 3550.0001253712823613575 3540.0001949804459468666 3531.3808814653596954e-5 3520.00516449860938221 3510.0018399881657893877 3500.00559401579533535 3491.2173849757291637e-5 3480.0006247601928733206 3470.0023908765062323513 3468.127040770543398e-6 3450.0001502865568886594 3442.203518410506149e-5 3430.007871976486581288 3420.001627995705982649 3410.00037722059020773885 3402.589105786500089e-5 3391.4067993944918593e-5 3380.0012046416898403465 3370.0015881938866834009 3363.9504451547182945e-5 3350.0005232860926543391 3342.2960635568379874e-5 3330.0023258757899790195 3320.014285458150672134 3310.0032096931423494035 3300.009976316294358592 3299.562549092647802e-5 3280.0015408567763339337 3270.0006424152796629789 3260.0002338547156581069 3250.0009515210111785614 3240.00018781008888875669 3230.016780790174380618 3220.0030620529856169496 3210.0006495375714091895 3200.004535342108014467 3190.0001785399356947014 3180.00013777495453064228 3178.959378203596414e-5 3160.005236737941418712 3150.0006647070272232951 3140.006891961444345595 3130.0009656615018615252 3120.00019159417223316074 3110.0004249599306021718 3100.00039892357458142414 3091.8398225646535842e-5 3080.0002269332594733762 3070.015887401157666816 3060.0014130339052405721 3050.0004524642436266437 3041.8055955910079735e-5 3030.0012298618999785822 3020.00061510954579215 3010.001566776269933333 3000.0015491183482287706 2990.00010325264683840255 2980.0004932326251880948 2970.005638884801427479 2960.021832829892110415 2950.004747906179906548 2945.702225272706921e-5 2930.0006605012791553149 2921.25877310084205e-5 2910.0012296559954180547 2906.218762622571532e-7 2890.0012865510593955281 2880.0011275394341154587 2870.00032027971460074975 2860.0016494076128949113 2850.0024729873233260676 2840.00010812938904281329 2830.0033693514197643275 2820.00019120046101210285 2810.000605419313512985 2800.0005622268454479876 2790.003413551991148032 2780.0014364324922485018 2770.002535962253350832 2760.00022918983553809076 2756.899101370754942e-5 2740.001344244406633948 2730.0002359743576967148 2720.002692786329418764 2710.03136920556341344 2700.00010204417687691191 2699.930137028546369e-6 2680.010769439925152852 2670.0037733313218273673 2660.0008243023559906009 2650.000859087940573227 2640.0003540723451473794 2630.0028440005914371143 2620.0003969011394360643 2612.322826616679532e-7 2600.0037191176547344738 2590.0011704039521652696 2580.0054473246853479216 2577.078813198049131e-5 2560.00034708216755413254 2550.00045480184269988276 2542.3477540453414368e-5 2530.00018346533295833945 2520.0001669929719398358 2510.0011528788112370237 2500.00012821330528407985 2490.036467547083882806 2480.00011796165579515642 2471.5806349690056328e-6 2460.0017758026044082688 2450.00037341782058820846 2444.9561787570503254e-5 2430.0014250713716124628 2420.0016671019374509875 2416.896184363398241e-5 2400.00458816468796128 2390.00034761927022711756 2380.00046634901787098693 2370.0004854073543230509 2360.00455481723325411 2350.0033290607535489247 2340.023929444141117508 2330.0009431023983179541 2320.0028271769926379205 2310.0010797281571716696 2300.0051656260336883685 2290.0027344168895289357 2280.00012997191883897736 2270.00017216788704077203 2260.002127639871726908 2250.000996720101878899 2240.0009773066396538063 2230.0006845977434991715 2220.0003035125466470814 2210.0007265928012457417 2200.0002947498539049859 2190.0007745645088202568 2180.0009429674099522844 2170.0005403581129007676 2160.0003787390543272519 2150.0032049582268393276 2140.0039124808422263905 2130.0006646323613652599 2127.19194516410555e-5 2110.0016038508868850198 2101.5221436942219521e-5 2090.002222634067210677 2081.2227905665228396e-5 2075.224159182196984e-6 2060.003793532392973678 2050.00029592220049991165 2040.000103310144193611 2031.961764099572084e-5 2020.004694315290398321 2010.000739625557046785 2000.0011157317397272012 1990.00032304551113302875 1980.0009454559991811538 1970.0004303989408126105 1960.00014032496610519527 1950.0008370520319530059 1940.0007465579921430649 1935.04625615595931e-5 1920.00031271026948410897 1910.005598429900736524 1900.00022094683650341178 1890.0029267288713430576 1881.1650361100961956e-5 1870.0019928041111623527 1860.006108152517891765 1850.00024273736270288024 1840.001362125853774087 1830.00027730514393639177 1820.005223819147972838 1810.005852023366925163 1800.00034811520782009633 1790.010671653579483499 1780.003051329690863437 1779.097220964457154e-5 1763.7746290833140266e-5 1750.0002852214066669927 1740.0008422522370072584 1730.0005064644473465469 1720.0006854553676335105 1710.00011457135673285262 1700.010733168629651502 1697.469226078566031e-5 1680.00023627710153710044 1670.0004342425407157875 1660.004594457326412528 1651.271526058200939e-5 1640.0006427758123491539 1630.001094987025637089 1620.0016753980238806137 1610.011506460086955593 1600.0029442998250862754 1590.0007135559804640387 1580.003010251345729358 1575.921466868414766e-7 1560.0004505542022666608 1558.064615768254158e-5 1540.0046263255535578755 1530.000567155256592415 1520.0003327420615603002 1512.1807091635788756e-5 1501.812570365886681e-5 1494.0382434369312024e-5 1481.9981030180751863e-5 1470.0007191874558119179 1460.00028998459630915816 1450.0023938818484598745 1440.0026422401201851575 1430.003210095579587302 1420.0024353305003544366 1410.00845022699797737 1400.00021480976707585091 1393.476645663675837e-5 1380.0030274604474655343 1370.0034525566850624424 1360.0003538775999285467 1350.0015653250955737765 1340.0005511197305903814 1330.0013406982362257844 1320.00038948591254292904 1310.00042467040098814995 1300.0026729560470619856 1299.99695660768476e-5 1280.002087216480028216 1270.00045884581789941886 1260.0005655005137109581 1252.473972760537631e-5 1240.0040229549937591865 1230.00023773097102363519 1220.0020747347277502355 1210.004504823758032139 1200.011832051478105277 1190.01347629400045614 1180.002392037664408508 1170.0004965616048766048 1160.0008659597940693063 1150.002619720464950992 1140.010068515062764224 1130.00010230910179887597 1120.0006341807061115013 1110.002745993600721201 1100.0024212186488399632 1090.000999154483149849 1086.884747182869322e-5 1070.0010913785947623982 1062.1766230150725065e-5 1050.00024336521037230134 1045.5546121201884256e-5 1030.0159604623733576 1020.00038920446705114974 1010.00025174696956344446 1002.652996425227019e-6 990.00012686749919350868 980.002693678008992801 970.0005929557896574876 960.0027620525929975596 957.001667840385103e-5 940.002350208481309809 931.1235528512080813e-5 920.00034242013846947587 910.0007817558874007508 900.0011144727717085055 890.0032897935458090347 885.389062196377045e-5 870.00030203677420888384 867.278469668888102e-5 850.003461072720237988 840.003965254011748425 830.001494869621505631 820.0027930399028539884 810.0004444246834202066 800.0005773301556597088 790.0005771539110612186 780.003683877963812546 770.009274109361922538 760.0009734236614871737 752.994370393654245e-5 740.00017568822803676413 730.0002120120866193807 720.0008588594083263419 710.0006919599107401467 700.0003981772882826605 690.00011125260127727051 680.02048379039262646 670.0005837753266020279 661.1554726292953081e-5 650.0015250598252616251 640.00011635730449740178 636.399597317557084e-7 622.6774616622841335e-7 610.00971392923064601 600.005122492198023358 592.493356502216212e-5 580.00034400876259600764 579.749303315022445e-5 560.006271672233962536 550.000931205883438282 541.241385022700763e-5 530.0013068997489010228 520.0016593619688357463 510.004460937230966017 500.0022332964148468215 492.4330696640821604e-5 489.121165079552248e-6 470.0001093357338402267 461.3263534770085183e-5 450.00021173014839731617 443.810659273265353e-6 430.007647471036740592 429.44018332752069e-5 410.0010808965187208744 400.0011032159189637478 390.00039969771320177093 386.163107491637179e-5 375.6838900781504785e-6 360.00031681595851193364 350.0005843944626518088 340.001990603154465277 330.0016564636493978685 320.0006311269835752428 310.003823713713882886 300.0038207465317389865 290.022448425318575292 280.00014487424992000502 270.00512562565974831 260.002307091077664991 250.00017390146174453347 240.0016157622268086712 230.0011870542770485819 220.00036791122732818265 210.022801101856814384 200.0004402248525852023 194.491081880693311e-5 180.00013088812712763395 170.0014220962769687271 160.0001816628274166637 150.0004061743811319311 140.0015523599544685622 130.0014022831343989647 120.0020909032219849745 110.0008737499110565024 100.0009203808571835729 96.516529231864065e-6 80.0008275623087761417 70.0003564350932106928 68.203423900751092e-5 50.0002863500223871526 40.00011930455277145942 30.0005118033831053014 20.0006783412311331946 11.2805900048658711e-5 h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? 0.00 0.01 0.02 0.03 0.04 0.000 0.002 0.004 0.006 0.008 0.010 0.012 0.014 0.016 0.018 0.020 0.022 0.024 0.026 0.028 0.030 0.032 0.034 0.036 0.038 0.040 0.042 0.0000 0.0002 0.0004 0.0006 0.0008 0.0010 0.0012 0.0014 0.0016 0.0018 0.0020 0.0022 0.0024 0.0026 0.0028 0.0030 0.0032 0.0034 0.0036 0.0038 0.0040 0.0042 0.0044 0.0046 0.0048 0.0050 0.0052 0.0054 0.0056 0.0058 0.0060 0.0062 0.0064 0.0066 0.0068 0.0070 0.0072 0.0074 0.0076 0.0078 0.0080 0.0082 0.0084 0.0086 0.0088 0.0090 0.0092 0.0094 0.0096 0.0098 0.0100 0.0102 0.0104 0.0106 0.0108 0.0110 0.0112 0.0114 0.0116 0.0118 0.0120 0.0122 0.0124 0.0126 0.0128 0.0130 0.0132 0.0134 0.0136 0.0138 0.0140 0.0142 0.0144 0.0146 0.0148 0.0150 0.0152 0.0154 0.0156 0.0158 0.0160 0.0162 0.0164 0.0166 0.0168 0.0170 0.0172 0.0174 0.0176 0.0178 0.0180 0.0182 0.0184 0.0186 0.0188 0.0190 0.0192 0.0194 0.0196 0.0198 0.0200 0.0202 0.0204 0.0206 0.0208 0.0210 0.0212 0.0214 0.0216 0.0218 0.0220 0.0222 0.0224 0.0226 0.0228 0.0230 0.0232 0.0234 0.0236 0.0238 0.0240 0.0242 0.0244 0.0246 0.0248 0.0250 0.0252 0.0254 0.0256 0.0258 0.0260 0.0262 0.0264 0.0266 0.0268 0.0270 0.0272 0.0274 0.0276 0.0278 0.0280 0.0282 0.0284 0.0286 0.0288 0.0290 0.0292 0.0294 0.0296 0.0298 0.0300 0.0302 0.0304 0.0306 0.0308 0.0310 0.0312 0.0314 0.0316 0.0318 0.0320 0.0322 0.0324 0.0326 0.0328 0.0330 0.0332 0.0334 0.0336 0.0338 0.0340 0.0342 0.0344 0.0346 0.0348 0.0350 0.0352 0.0354 0.0356 0.0358 0.0360 0.0362 0.0364 0.0366 0.0368 0.0370 0.0372 0.0374 0.0376 0.0378 0.0380 0.0382 0.0384 0.0386 0.0388 0.0390 0.0392 0.0394 0.0396 0.0398 0.0400 0.0402 0.00 0.05 Cook's Distance
Figure 8: Cook’s distance for each oservation (index).
cook_lev_plot(bw_perf)
Leverage 0.00 0.01 0.02 0.03 0.04 0.000 0.002 0.004 0.006 0.008 0.010 0.012 0.014 0.016 0.018 0.020 0.022 0.024 0.026 0.028 0.030 0.032 0.034 0.036 0.038 0.040 0.042 0.0000 0.0002 0.0004 0.0006 0.0008 0.0010 0.0012 0.0014 0.0016 0.0018 0.0020 0.0022 0.0024 0.0026 0.0028 0.0030 0.0032 0.0034 0.0036 0.0038 0.0040 0.0042 0.0044 0.0046 0.0048 0.0050 0.0052 0.0054 0.0056 0.0058 0.0060 0.0062 0.0064 0.0066 0.0068 0.0070 0.0072 0.0074 0.0076 0.0078 0.0080 0.0082 0.0084 0.0086 0.0088 0.0090 0.0092 0.0094 0.0096 0.0098 0.0100 0.0102 0.0104 0.0106 0.0108 0.0110 0.0112 0.0114 0.0116 0.0118 0.0120 0.0122 0.0124 0.0126 0.0128 0.0130 0.0132 0.0134 0.0136 0.0138 0.0140 0.0142 0.0144 0.0146 0.0148 0.0150 0.0152 0.0154 0.0156 0.0158 0.0160 0.0162 0.0164 0.0166 0.0168 0.0170 0.0172 0.0174 0.0176 0.0178 0.0180 0.0182 0.0184 0.0186 0.0188 0.0190 0.0192 0.0194 0.0196 0.0198 0.0200 0.0202 0.0204 0.0206 0.0208 0.0210 0.0212 0.0214 0.0216 0.0218 0.0220 0.0222 0.0224 0.0226 0.0228 0.0230 0.0232 0.0234 0.0236 0.0238 0.0240 0.0242 0.0244 0.0246 0.0248 0.0250 0.0252 0.0254 0.0256 0.0258 0.0260 0.0262 0.0264 0.0266 0.0268 0.0270 0.0272 0.0274 0.0276 0.0278 0.0280 0.0282 0.0284 0.0286 0.0288 0.0290 0.0292 0.0294 0.0296 0.0298 0.0300 0.0302 0.0304 0.0306 0.0308 0.0310 0.0312 0.0314 0.0316 0.0318 0.0320 0.0322 0.0324 0.0326 0.0328 0.0330 0.0332 0.0334 0.0336 0.0338 0.0340 0.0342 0.0344 0.0346 0.0348 0.0350 0.0352 0.0354 0.0356 0.0358 0.0360 0.0362 0.0364 0.0366 0.0368 0.0370 0.0372 0.0374 0.0376 0.0378 0.0380 0.0382 0.0384 0.0386 0.0388 0.0390 0.0392 0.0394 0.0396 0.0398 0.0400 0.0402 0.00 0.05 0.0022824642516868790.00023662511890588226 0.0020488017979967077.881040184924393e-5 0.00207604817383451848.644460748465718e-6 0.0020528001985361940.0010643104145528711 0.0024491960747887340.00014525858895261232 0.00218510846201681870.004162717829481287 0.0022630721985796120.00031818070090998575 0.00220982939282685130.00010108509341032247 0.0028556389976220870.0011981011133397267 0.0053163118439804310.0031892402677983086 0.002089741256023320.0002660414764800312 0.00204658551794352281.430706253806959e-7 0.00204179399064809141.8585122433396184e-6 0.00240745012247234247.13806347542578e-5 0.00375523877187708930.0009383259806951895 0.0020500499914684870.00026083472070654424 0.00207042125718379450.000726338793997241 0.0025424830398386190.00017668803955867167 0.0035128677774406180.0023580048099584488 0.00247530213478299550.001247069403699668 0.00219372074021764040.001381366958238154 0.0046361394855410410.0006526017564487266 0.00328397133861849920.004122649277227561 0.0023783216956818810.0007244945853838828 0.0092300145887168390.0016498603699317937 0.00372024032679163075.950219461074403e-5 0.0115208114294495960.006131882123001953 0.00315774277624255975.188597963920474e-6 0.0029510582473372520.0029400137954462536 0.0022385100887432150.0006385895642018009 0.00204209537147950850.00017227247336228164 0.0087817680457000950.0065214137932582865 0.00205380480130758430.0002917356924134019 0.004034881181206970.0007442845539438667 0.00264540045716793161.0818323440332155e-6 0.0039536897965433330.0026409385142668637 0.0022191631103079630.0003960405812940194 0.007482201144415620.011072019803415229 0.0061116480331924580.00095612886427354 0.00204728873988349650.0003454621864191554 0.0021817129046495190.000561016156226434 0.0088282574755485340.0027055701201282533 0.0021623030009940220.00031692554208390925 0.0024350078232825945.642790973515522e-5 0.0076396869948544880.004206913544524141 0.0020868325947740650.0001418981036123633 0.00236039338752947260.0018408431265151527 0.0069834036827720020.0038817722213864056 0.00291732107797467320.0003628498664581898 0.0079288229615060240.0030755988553921453 0.0022287239536002297.77582939622805e-6 0.0028923479164728716.75301371683378e-5 0.00204209537147950850.0008646236824932802 0.0023478566785266930.0004576551935045808 0.00311101407568942350.0005047290842107223 0.00744071149825863060.002332923230727402 0.00232359399329724970.00016207171943626375 0.0044314775704670250.0019167092615322802 0.0047673421154076670.0022424324891730193 0.0030205521432929776.266409986001001e-5 0.00206815949491183240.0029180137088542922 0.018469056144654770.0010594553372858197 0.0025681237629386113.066083635880601e-5 0.0020492061251405193.50658696994479e-5 0.0022287239536002291.6322232254001984e-5 0.00207603790365608469.481798477547418e-5 0.002051377534295070.002800057369717816 0.00511733549153636950.004704407087511269 0.0020509287845540650.009820240349285287 0.00254883331123942043.3828048985241366e-6 0.00204083617424512120.00011563455458454085 0.0100173075572735580.0007189162389041117 0.00286778543984438730.00022059733173164322 0.00205647606656725150.008280038274786869 0.00216863277279263263.16135801762791e-5 0.0050471960415076710.002875274454005806 0.0026078242380502930.00036818094180539486 0.0030117795361954961.4927351134415662e-5 0.00457877846050040.00036798283858081155 0.0021834159610637530.004426139908153967 0.00226518394288802469.597235988877333e-5 0.0026842260516429630.00018847394609815905 0.00275413413737417032.648767510251428e-5 0.0029256570394700170.008941776532167869 0.00204089645041140470.0004225660989337255 0.0023404730315530160.00024186490429274502 0.0047086304396389680.001090585397704927 0.0022385100887432150.0001272352245808718 0.00262136400114676340.0012783441693206272 0.0040921574772755320.0003313728669385025 0.0033701170655094830.0005654967802591556 0.0038082313031625440.0011248614000574158 0.0024723255762429842.6314308317311937e-5 0.00276550175773191553.03926059973845e-5 0.00208779619834107340.0010434446212203847 0.00239404570565594470.0006309916722744048 0.00205647606656725150.00014559589676686597 0.0036401423493390940.001597707193353765 0.0060577299632076820.008279724448889844 0.0021834159610637534.486273740677786e-5 0.0029383127113729870.015187229377906678 0.00218510846201681870.002473960398304343 0.00286377628007035032.0530943723395385e-5 0.0020432313265726920.0005028852492103339 0.0079505300024925310.00751249480926151 0.00206000350606713650.00038371009039566637 0.00230951565715315550.0001493231613142968 0.0021115071060077640.00043781876866406407 0.00205232186090017730.0010091422922430425 0.00206458115282121860.00036884589536825585 0.008631780729667460.004482233537546226 0.00210570514802222750.0011334342733075704 0.0024183870066560170.0004909544146328206 0.0024520217187623173.09273949425335e-6 0.00223066607694578055.751071212294259e-6 0.0020840016934472360.0002473063400332687 0.00226946355069414850.0005802317549531363 0.00223064223546013070.000923900870371063 0.00204728873988349651.5231226937846543e-10 0.0031530826827782740.00021774088703639048 0.00205591511920232571.466320617733652e-7 0.00281584804712896540.0015427709756963743 0.00215016185687964480.0007571138864011179 0.0027206155760953940.001543682121430787 0.00358968422911021050.0010598392463174856 0.00214433092231924172.002799456644544e-5 0.0147736978824746860.0011068997256421579 0.00266647156218507730.0002021671579164067 0.00425520581122185850.0030439086808294455 0.00302503466863251850.00022970026030264082 0.0045788656347530570.00024117680393425314 0.0023478870000058780.00013061548423252953 0.0031863178360378910.004908206992862532 0.0032054699663656384.5123675757605094e-5 0.0055802306508830128.535539091723279e-5 0.00332915633354182940.0001253712823613575 0.0022913310835960210.0001949804459468666 0.00204209341525504521.3808814653596954e-5 0.0165881598534947040.00516449860938221 0.00745097356651172950.0018399881657893877 0.0090040156851173380.00559401579533535 0.0024811770028844761.2173849757291637e-5 0.00237828990703434820.0006247601928733206 0.0035236648323298260.0023908765062323513 0.0037904533797657728.127040770543398e-6 0.0022267682181927850.0001502865568886594 0.00231186557179000662.203518410506149e-5 0.00372031123992843430.007871976486581288 0.00242945051561903150.001627995705982649 0.0034538314091656440.00037722059020773885 0.00204243277944479632.589105786500089e-5 0.00210232149102041431.4067993944918593e-5 0.00208876978680378130.0012046416898403465 0.0023628935646579310.0015881938866834009 0.00244067378291323643.9504451547182945e-5 0.002051377534295070.0005232860926543391 0.0020553710035187222.2960635568379874e-5 0.0028476404440920310.0023258757899790195 0.0184509484751718550.014285458150672134 0.00345914842725759950.0032096931423494035 0.00300299270571597860.009976316294358592 0.0020606352035501619.562549092647802e-5 0.0057677114947950230.0015408567763339337 0.00259777425713278440.0006424152796629789 0.00322484041949445270.0002338547156581069 0.00213046891199707630.0009515210111785614 0.00246066346259412060.00018781008888875669 0.0265129125729125330.016780790174380618 0.0040159949343875620.0030620529856169496 0.0038440567421399720.0006495375714091895 0.0032493382999609630.004535342108014467 0.0020513831584404030.0001785399356947014 0.00210232149102041430.00013777495453064228 0.00252990231578540888.959378203596414e-5 0.010965243070478510.005236737941418712 0.0021264997325605140.0006647070272232951 0.0120367337208018910.006891961444345595 0.0022980582949981450.0009656615018615252 0.00291732107797467320.00019159417223316074 0.00377276532043029430.0004249599306021718 0.0022630721985796120.00039892357458142414 0.00232359399329724971.8398225646535842e-5 0.0139271751239491560.0002269332594733762 0.0154358737094334990.015887401157666816 0.0055719312463323310.0014130339052405721 0.0039351929606562030.0004524642436266437 0.00411776001324380951.8055955910079735e-5 0.00287185422370988580.0012298618999785822 0.00215166277009931060.00061510954579215 0.00381417724741953340.001566776269933333 0.0030652838647062290.0015491183482287706 0.00270227344495959070.00010325264683840255 0.00215615254977123820.0004932326251880948 0.0029985607161750790.005638884801427479 0.0043154591141318710.021832829892110415 0.0065465585864943510.004747906179906548 0.004034881181206975.702225272706921e-5 0.0023478566785266930.0006605012791553149 0.00233076795746123841.25877310084205e-5 0.00221169416379673940.0012296559954180547 0.00260446425951542436.218762622571532e-7 0.00241019421633860030.0012865510593955281 0.0021576751852333850.0011275394341154587 0.00252678209701135470.00032027971460074975 0.00306076576053425670.0016494076128949113 0.0044315621771750730.0024729873233260676 0.0020462551197825630.00010812938904281329 0.0102843924727157340.0033693514197643275 0.0021751032297339140.00019120046101210285 0.0021623220741825420.000605419313512985 0.00221167154495137970.0005622268454479876 0.00219723554576786460.003413551991148032 0.0050627126916885970.0014364324922485018 0.0135754607593486390.002535962253350832 0.0034220746725443620.00022918983553809076 0.0020581914308937356.899101370754942e-5 0.0021318119416006630.001344244406633948 0.00204962557226924740.0002359743576967148 0.0114660227988238590.002692786329418764 0.0278572825978031830.03136920556341344 0.0022405264671090290.00010204417687691191 0.0025144010708721339.930137028546369e-6 0.0075241058361962940.010769439925152852 0.00292145845196042570.0037733313218273673 0.0033701170655094830.0008243023559906009 0.00418928646717184850.000859087940573227 0.00374932102985611660.0003540723451473794 0.00210684847971182550.0028440005914371143 0.002713221699697960.0003969011394360643 0.0035841276957854982.322826616679532e-7 0.0077245980588262320.0037191176547344738 0.00290476395087905550.0011704039521652696 0.0143154642837606780.0054473246853479216 0.0021034347457588857.078813198049131e-5 0.00358968422911021050.00034708216755413254 0.00300299270571597860.00045480184269988276 0.0021487071187082542.3477540453414368e-5 0.00251136831163347070.00018346533295833945 0.0021902247225732010.0001669929719398358 0.00354010188612085630.0011528788112370237 0.00237573055411586730.00012821330528407985 0.03188594385125290.036467547083882806 0.0021264837159727190.00011796165579515642 0.0029215098028525941.5806349690056328e-6 0.00508596706547110450.0017758026044082688 0.00204393507832345770.00037341782058820846 0.0021079876136697624.9561787570503254e-5 0.00287598299845893360.0014250713716124628 0.0055466816458610220.0016671019374509875 0.00205879280689757466.896184363398241e-5 0.00300738112850788740.00458816468796128 0.00333423359187296930.00034761927022711756 0.00204841222404572460.00046634901787098693 0.00208779619834107340.0004854073543230509 0.0021239035374146360.00455481723325411 0.0052759981332540990.0033290607535489247 0.010452033084344940.023929444141117508 0.00229357275381255470.0009431023983179541 0.00264540045716793160.0028271769926379205 0.0040222803650983320.0010797281571716696 0.00230261128517305050.0051656260336883685 0.00272430505618834370.0027344168895289357 0.002246537700357490.00012997191883897736 0.00204081632671775140.00017216788704077203 0.00204962557226924740.002127639871726908 0.00379644187190484370.000996720101878899 0.0023453854779731010.0009773066396538063 0.0048042704574357810.0006845977434991715 0.025269055683976130.0003035125466470814 0.0022154086672609520.0007265928012457417 0.0020711856111382540.0002947498539049859 0.00249315549508564340.0007745645088202568 0.00205819864447144480.0009429674099522844 0.0047305724313344840.0005403581129007676 0.0053164108778438990.0003787390543272519 0.0020408610753523550.0032049582268393276 0.00687472375798383550.0039124808422263905 0.0117842078836657290.0006646323613652599 0.0025681237629386117.19194516410555e-5 0.00297681891144966660.0016038508868850198 0.031520870185262681.5221436942219521e-5 0.00214724427035627420.002222634067210677 0.00204089645041140471.2227905665228396e-5 0.0020450167481877775.224159182196984e-6 0.00205329438974130060.003793532392973678 0.0040412739597351770.00029592220049991165 0.0021654381359796110.000103310144193611 0.0027617025660503011.961764099572084e-5 0.0092538514690880480.004694315290398321 0.00252057161415034530.000739625557046785 0.00212913586728918960.0011157317397272012 0.0042752003814639010.00032304551113302875 0.0099417614696196660.0009454559991811538 0.0069635538323855870.0004303989408126105 0.00300738112850788740.00014032496610519527 0.0029340841691762980.0008370520319530059 0.00204962043718003030.0007465579921430649 0.002051377534295075.04625615595931e-5 0.00279237567658280040.00031271026948410897 0.0030926582917370510.005598429900736524 0.00247825273259418820.00022094683650341178 0.0059599220819131580.0029267288713430576 0.0028882292081288751.1650361100961956e-5 0.00383214822571805240.0019928041111623527 0.0170866425667730720.006108152517891765 0.00359525074733062220.00024273736270288024 0.00204113535432401670.001362125853774087 0.0020786094829774630.00027730514393639177 0.0059158134995009010.005223819147972838 0.0031342536147697490.005852023366925163 0.0020415359727922830.00034811520782009633 0.0071437639197773380.010671653579483499 0.00343794026426397530.003051329690863437 0.0244578404947559779.097220964457154e-5 0.00379644187190484373.7746290833140266e-5 0.0029812003651919240.0002852214066669927 0.00211511646240706030.0008422522370072584 0.00204301927999177720.0005064644473465469 0.00299419238543859740.0006854553676335105 0.00302498038340365480.00011457135673285262 0.011099240982084860.010733168629651502 0.0021345279554949347.469226078566031e-5 0.00270591287831001450.00023627710153710044 0.0026986439965048660.0004342425407157875 0.0062571868947949580.004594457326412528 0.00274665161955573061.271526058200939e-5 0.0043902003784377140.0006427758123491539 0.00278855390681050170.001094987025637089 0.00204301927999177720.0016753980238806137 0.008517693392915250.011506460086955593 0.00211633955099822450.0029442998250862754 0.00210233506232763040.0007135559804640387 0.00455755269148660350.003010251345729358 0.00283166436644490335.921466868414766e-7 0.0021264997325605140.0004505542022666608 0.00295960519579192588.064615768254158e-5 0.0052360318561434310.0046263255535578755 0.0022868505552356190.000567155256592415 0.0025944035193633660.0003327420615603002 0.0032789329194938962.1807091635788756e-5 0.0032054699663656381.812570365886681e-5 0.0021592078055912314.0382434369312024e-5 0.00252367186313300031.9981030180751863e-5 0.00227375717810892730.0007191874558119179 0.00214291563467453260.00028998459630915816 0.00215017995195593240.0023938818484598745 0.00256165367278941670.0026422401201851575 0.00360089559603892850.003210095579587302 0.0034858175131052790.0024353305003544366 0.0056223915673137370.00845022699797737 0.00208586736102000330.00021480976707585091 0.00215313723353404263.476645663675837e-5 0.033493890466029050.0030274604474655343 0.0020488017979967070.0034525566850624424 0.00212388776535489850.0003538775999285467 0.0063680185034743360.0015653250955737765 0.0027391628255171370.0005511197305903814 0.00289647660971256630.0013406982362257844 0.00224656251995537140.00038948591254292904 0.0047820292856613680.00042467040098814995 0.0022007902909008870.0026729560470619856 0.00244631048068627839.99695660768476e-5 0.00286778543984438730.002087216480028216 0.00377276532043029430.00045884581789941886 0.0022652098628621670.0005655005137109581 0.00211633955099822452.473972760537631e-5 0.00343266318575481760.0040229549937591865 0.0025811837619853930.00023773097102363519 0.00206965735153077450.0020747347277502355 0.00204141974045540670.004504823758032139 0.0146940929958509940.011832051478105277 0.0129026008494633870.01347629400045614 0.0065844646739621580.002392037664408508 0.00306981195377390140.0004965616048766048 0.0057074622673526420.0008659597940693063 0.0051881866404777190.002619720464950992 0.0075031973423376810.010068515062764224 0.00415666051481392450.00010230910179887597 0.0020509232826727610.0006341807061115013 0.00205878547105583630.002745993600721201 0.0031295857371622850.0024212186488399632 0.00221728089633660770.000999154483149849 0.00307435002773727256.884747182869322e-5 0.00233806161810959150.0010913785947623982 0.0022980860489327212.1766230150725065e-5 0.00222870023437860820.00024336521037230134 0.00251443872819305665.5546121201884256e-5 0.0040538572920876730.0159604623733576 0.0037029117237013330.00038920446705114974 0.00204081632671775140.00025174696956344446 0.0020794724632486272.652996425227019e-6 0.00262477390416012950.00012686749919350868 0.004124205202285770.002693678008992801 0.0029985607161750790.0005929557896574876 0.0052679653457959310.0027620525929975596 0.00211390335871159557.001667840385103e-5 0.0020969049907635520.002350208481309809 0.00246647454962715341.1235528512080813e-5 0.0031296428344638150.00034242013846947587 0.0020513831584404030.0007817558874007508 0.0046289453070575950.0011144727717085055 0.0059863983573871480.0032897935458090347 0.0031202799366344565.389062196377045e-5 0.00206815949491183240.00030203677420888384 0.00234050298624011437.278469668888102e-5 0.0063866302267940240.003461072720237988 0.0070632024801456430.003965254011748425 0.0021989861628893690.001494869621505631 0.0040286529293070830.0027930399028539884 0.0022405020143032350.0004444246834202066 0.00252990231578540880.0005773301556597088 0.002246537700357490.0005771539110612186 0.0062940838557223010.003683877963812546 0.0114658548080480510.009274109361922538 0.00297681891144966660.0009734236614871737 0.00205431272683861272.994370393654245e-5 0.00240745012247234240.00017568822803676413 0.00350204402823841960.0002120120866193807 0.0030161879287788040.0008588594083263419 0.0023628935646579310.0006919599107401467 0.0020537985658421070.0003981772882826605 0.00227373076907866950.00011125260127727051 0.0091344786176086810.02048379039262646 0.0023453854779731010.0005837753266020279 0.00225890421783194041.1554726292953081e-5 0.0022759189691598660.0015250598252616251 0.0021654381359796110.00011635730449740178 0.00217672563264370266.399597317557084e-7 0.00262136400114676342.6774616622841335e-7 0.0063125360652388560.00971392923064601 0.008483619752944940.005122492198023358 0.0024578082307255262.493356502216212e-5 0.00483406514167478850.00034400876259600764 0.00232122264170065189.749303315022445e-5 0.0113155478530890060.006271672233962536 0.00235536087783293650.000931205883438282 0.00257463379267060341.241385022700763e-5 0.00205819864447144480.0013068997489010228 0.0040602026321726390.0016593619688357463 0.006933974984912390.004460937230966017 0.0028556389976220870.0022332964148468215 0.0034965811084052242.4330696640821604e-5 0.0021800404957518819.121165079552248e-6 0.0035897523301743480.0001093357338402267 0.00208682085742728331.3263534770085183e-5 0.002051377534295070.00021173014839731617 0.00306981195377390143.810659273265353e-6 0.0038681400660389130.007647471036740592 0.0020424349801973189.44018332752069e-5 0.00270591287831001450.0010808965187208744 0.0020768919586531340.0011032159189637478 0.0021264997325605140.00039969771320177093 0.00214006256280378356.163107491637179e-5 0.00335976965696416135.6838900781504785e-6 0.00295532672911673950.00031681595851193364 0.00272795916122224460.0005843944626518088 0.0050239014428596320.001990603154465277 0.004826692824501130.0016564636493978685 0.00235536087783293650.0006311269835752428 0.0052679653457959310.003823713713882886 0.0059421406128595460.0038207465317389865 0.0112477919403051250.022448425318575292 0.0038440567421399720.00014487424992000502 0.0020441896320317780.00512562565974831 0.0042154862629216560.002307091077664991 0.0030383250131098850.00017390146174453347 0.0024723615218675020.0016157622268086712 0.0039290473184852240.0011870542770485819 0.0021817129046495190.00036791122732818265 0.0207337826672443980.022801101856814384 0.00233806161810959150.0004402248525852023 0.00214577367861579354.491081880693311e-5 0.00298548567865273340.00013088812712763395 0.00425520581122185850.0014220962769687271 0.0022673056720921370.0001816628274166637 0.00209378750255281160.0004061743811319311 0.00341159065432400070.0015523599544685622 0.00208975336016218850.0014022831343989647 0.0021345279554949340.0020909032219849745 0.00289652722702056060.0008737499110565024 0.0059245074093184010.0009203808571835729 0.00239670661922782546.516529231864065e-6 0.0054140832090849680.0008275623087761417 0.0040538572920876730.0003564350932106928 0.0032394731007459088.203423900751092e-5 0.00346974700687310760.0002863500223871526 0.00206000350606713650.00011930455277145942 0.0039167859888303670.0005118033831053014 0.00338044156992671140.0006783412311331946 0.0021751032297339141.2805900048658711e-5 h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? 0.00 0.01 0.02 0.03 0.04 0.000 0.002 0.004 0.006 0.008 0.010 0.012 0.014 0.016 0.018 0.020 0.022 0.024 0.026 0.028 0.030 0.032 0.034 0.036 0.038 0.040 0.042 0.0000 0.0002 0.0004 0.0006 0.0008 0.0010 0.0012 0.0014 0.0016 0.0018 0.0020 0.0022 0.0024 0.0026 0.0028 0.0030 0.0032 0.0034 0.0036 0.0038 0.0040 0.0042 0.0044 0.0046 0.0048 0.0050 0.0052 0.0054 0.0056 0.0058 0.0060 0.0062 0.0064 0.0066 0.0068 0.0070 0.0072 0.0074 0.0076 0.0078 0.0080 0.0082 0.0084 0.0086 0.0088 0.0090 0.0092 0.0094 0.0096 0.0098 0.0100 0.0102 0.0104 0.0106 0.0108 0.0110 0.0112 0.0114 0.0116 0.0118 0.0120 0.0122 0.0124 0.0126 0.0128 0.0130 0.0132 0.0134 0.0136 0.0138 0.0140 0.0142 0.0144 0.0146 0.0148 0.0150 0.0152 0.0154 0.0156 0.0158 0.0160 0.0162 0.0164 0.0166 0.0168 0.0170 0.0172 0.0174 0.0176 0.0178 0.0180 0.0182 0.0184 0.0186 0.0188 0.0190 0.0192 0.0194 0.0196 0.0198 0.0200 0.0202 0.0204 0.0206 0.0208 0.0210 0.0212 0.0214 0.0216 0.0218 0.0220 0.0222 0.0224 0.0226 0.0228 0.0230 0.0232 0.0234 0.0236 0.0238 0.0240 0.0242 0.0244 0.0246 0.0248 0.0250 0.0252 0.0254 0.0256 0.0258 0.0260 0.0262 0.0264 0.0266 0.0268 0.0270 0.0272 0.0274 0.0276 0.0278 0.0280 0.0282 0.0284 0.0286 0.0288 0.0290 0.0292 0.0294 0.0296 0.0298 0.0300 0.0302 0.0304 0.0306 0.0308 0.0310 0.0312 0.0314 0.0316 0.0318 0.0320 0.0322 0.0324 0.0326 0.0328 0.0330 0.0332 0.0334 0.0336 0.0338 0.0340 0.0342 0.0344 0.0346 0.0348 0.0350 0.0352 0.0354 0.0356 0.0358 0.0360 0.0362 0.0364 0.0366 0.0368 0.0370 0.0372 0.0374 0.0376 0.0378 0.0380 0.0382 0.0384 0.0386 0.0388 0.0390 0.0392 0.0394 0.0396 0.0398 0.0400 0.0402 0.00 0.05 Cook's Distance
Figure 9: Cook’s Distance vs Leverage.

6.3.1 Collinearity

When more than two variables are involved, it is often called multicollinearity. However, the terms collinearity and multicollinearity are often used interchangeably. The variance inflation factor (VIF) is used to test for collinearity. The rule of thumb is:

  • Values larger than 10 give evidence of collinearity.
  • A mean of the VIF factors considerably greater than 1 suggests collinearity.
using MixedModelsExtras: gvif
r3.(gvif(model_2))
3-element Vector{Float64}:
 1.05
 1.053
 1.004

The results from gvif follow the same order as the coefficients of the model, this is:

  • Gestational weeks.
  • Hypertension.
  • Sex.

7 Effect Plots

We can plot all the predictors who have an effect on birth weight.

plot(
  babies_cat,
  x=:Gestation, y=:bweight,
  color=:Sex, xgroup=:Hypertension,
  Geom.subplot_grid(Geom.point, Geom.smooth(method=:lm)),
  Guide.xlabel("Gestational weeks"),
  Guide.ylabel("Birth weight (g)")
)
Gestational weeks Female Male Sex Hypertension No hypertension 30 35 40 30.0 30.5 31.0 31.5 32.0 32.5 33.0 33.5 34.0 34.5 35.0 35.5 36.0 36.5 37.0 37.5 38.0 38.5 39.0 39.5 40.0 29.95 30.00 30.05 30.10 30.15 30.20 30.25 30.30 30.35 30.40 30.45 30.50 30.55 30.60 30.65 30.70 30.75 30.80 30.85 30.90 30.95 31.00 31.05 31.10 31.15 31.20 31.25 31.30 31.35 31.40 31.45 31.50 31.55 31.60 31.65 31.70 31.75 31.80 31.85 31.90 31.95 32.00 32.05 32.10 32.15 32.20 32.25 32.30 32.35 32.40 32.45 32.50 32.55 32.60 32.65 32.70 32.75 32.80 32.85 32.90 32.95 33.00 33.05 33.10 33.15 33.20 33.25 33.30 33.35 33.40 33.45 33.50 33.55 33.60 33.65 33.70 33.75 33.80 33.85 33.90 33.95 34.00 34.05 34.10 34.15 34.20 34.25 34.30 34.35 34.40 34.45 34.50 34.55 34.60 34.65 34.70 34.75 34.80 34.85 34.90 34.95 35.00 35.05 35.10 35.15 35.20 35.25 35.30 35.35 35.40 35.45 35.50 35.55 35.60 35.65 35.70 35.75 35.80 35.85 35.90 35.95 36.00 36.05 36.10 36.15 36.20 36.25 36.30 36.35 36.40 36.45 36.50 36.55 36.60 36.65 36.70 36.75 36.80 36.85 36.90 36.95 37.00 37.05 37.10 37.15 37.20 37.25 37.30 37.35 37.40 37.45 37.50 37.55 37.60 37.65 37.70 37.75 37.80 37.85 37.90 37.95 38.00 38.05 38.10 38.15 38.20 38.25 38.30 38.35 38.40 38.45 38.50 38.55 38.60 38.65 38.70 38.75 38.80 38.85 38.90 38.95 39.00 39.05 39.10 39.15 39.20 39.25 39.30 39.35 39.40 39.45 39.50 39.55 39.60 39.65 39.70 39.75 39.80 39.85 39.90 39.95 40.00 30 40 30 35 40 30.0 30.5 31.0 31.5 32.0 32.5 33.0 33.5 34.0 34.5 35.0 35.5 36.0 36.5 37.0 37.5 38.0 38.5 39.0 39.5 40.0 29.95 30.00 30.05 30.10 30.15 30.20 30.25 30.30 30.35 30.40 30.45 30.50 30.55 30.60 30.65 30.70 30.75 30.80 30.85 30.90 30.95 31.00 31.05 31.10 31.15 31.20 31.25 31.30 31.35 31.40 31.45 31.50 31.55 31.60 31.65 31.70 31.75 31.80 31.85 31.90 31.95 32.00 32.05 32.10 32.15 32.20 32.25 32.30 32.35 32.40 32.45 32.50 32.55 32.60 32.65 32.70 32.75 32.80 32.85 32.90 32.95 33.00 33.05 33.10 33.15 33.20 33.25 33.30 33.35 33.40 33.45 33.50 33.55 33.60 33.65 33.70 33.75 33.80 33.85 33.90 33.95 34.00 34.05 34.10 34.15 34.20 34.25 34.30 34.35 34.40 34.45 34.50 34.55 34.60 34.65 34.70 34.75 34.80 34.85 34.90 34.95 35.00 35.05 35.10 35.15 35.20 35.25 35.30 35.35 35.40 35.45 35.50 35.55 35.60 35.65 35.70 35.75 35.80 35.85 35.90 35.95 36.00 36.05 36.10 36.15 36.20 36.25 36.30 36.35 36.40 36.45 36.50 36.55 36.60 36.65 36.70 36.75 36.80 36.85 36.90 36.95 37.00 37.05 37.10 37.15 37.20 37.25 37.30 37.35 37.40 37.45 37.50 37.55 37.60 37.65 37.70 37.75 37.80 37.85 37.90 37.95 38.00 38.05 38.10 38.15 38.20 38.25 38.30 38.35 38.40 38.45 38.50 38.55 38.60 38.65 38.70 38.75 38.80 38.85 38.90 38.95 39.00 39.05 39.10 39.15 39.20 39.25 39.30 39.35 39.40 39.45 39.50 39.55 39.60 39.65 39.70 39.75 39.80 39.85 39.90 39.95 40.00 30 40 38.02999877929693187.0 39.22000122070313095.0 31.29000091552731324.0 36.36999893188483093.0 34.1899986267091874.0 37.54000091552732697.0 37.11000061035162622.0 37.95999908447273562.0 36.99000167846682732.0 38.25999832153323160.0 38.6899986267092924.0 39.34999847412112769.0 32.52999877929691541.0 39.04000091552732558.0 35.52606.0 39.63000106811523040.0 38.86999893188483392.0 36.24000167846682736.0 38.77000045776372646.0 38.22999954223633092.0 38.5600013732913576.0 38.47999954223633813.0 39.6899986267093291.0 37.22000122070312090.0 34.02000045776371570.0 37.74000167846682718.0 38.753367.0 38.18000030517583096.0 39.9399986267093216.0 36.9399986267092404.0 37.59000015258792992.0 37.9399986267092842.0 36.84999847412111999.0 37.63000106811523261.0 37.22000122070312428.0 37.04000091552733178.0 37.25999832153322959.0 35.13999938964841663.0 37.95999908447272092.0 37.70000076293953773.0 39.45999908447273138.0 36.36999893188482418.0 38.47999954223632507.0 37.88999938964841946.0 37.68000030517582213.0 36.47999954223632002.0 37.61999893188482849.0 38.4399986267093079.0 39.43000030517583542.0 39.58000183105473234.0 39.04000091552733743.0 38.50999832153323120.0 36.52999877929693164.0 38.88999938964843200.0 37.97000122070312918.0 39.91999816894533178.0 38.53054.0 38.45000076293952852.0 38.02999877929693349.0 39.43000030517583322.0 38.90999984741213542.0 39.65999984741213948.0 37.59000015258793237.0 38.25999832153323172.0 38.09000015258793152.0 38.09000015258792552.0 39.54000091552733061.0 38.84999847412113455.0 39.52000045776372595.0 39.88000106811522843.0 39.70000076293952963.0 34.34000015258792417.0 39.79999923706052639.0 39.5600013732912878.0 31.70999908447271938.0 37.09999847412113565.0 38.47999954223633337.0 38.93000030517583122.0 39.02000045776373087.0 39.5600013732913770.0 39.86000061035163486.0 38.90000152587893757.0 36.09000015258792949.0 39.20000076293953102.0 38.753294.0 39.0600013732913419.0 39.18000030517584197.0 39.43000030517583042.0 35.97000122070312719.0 37.9399986267092944.0 38.97999954223633601.0 31.37000083923342098.0 39.9399986267093830.0 38.45000076293952399.0 39.90000152587893581.0 39.43000030517583463.0 39.74000167846683179.0 37.86000061035162944.0 39.56999969482422353.0 39.90000152587893457.0 38.86000061035163140.0 38.68000030517582978.0 37.36000061035162362.0 38.66999816894532801.0 39.59999847412113350.0 39.74000167846683516.0 36.27999877929693559.0 39.49000167846683134.0 39.38000106811523383.0 35.95000076293952407.0 39.90000152587893337.0 39.70000076293952797.0 34.0600013732912497.0 39.77000045776373041.0 38.83000183105473404.0 39.63999938964843082.0 38.36000061035163704.0 37.90999984741214035.0 37.81999969482422969.0 38.04999923706054226.0 39.753200.0 38.36000061035163257.0 39.95999908447273090.0 39.75999832153323207.0 39.56999969482424287.0 38.15000152587892863.0 39.49000167846683425.0 37.95999908447272943.0 37.65000152587893045.0 37.27000045776373333.0 38.95000076293953102.0 36.4399986267092666.0 39.40000152587893193.0 38.752744.0 38.77999877929693695.0 39.16999816894533282.0 38.22999954223632784.0 38.88999938964843804.0 37.79000091552732694.0 36.22999954223632425.0 37.52999877929692890.0 33.22999954223632659.0 38.90999984741212914.0 38.97000122070313154.0 32.40999984741211431.0 39.13000106811524319.0 37.79000091552733683.0 38.29000091552733331.0 38.22999954223632905.0 38.54999923706053156.0 39.95999908447273249.0 38.06999969482422855.0 38.72000122070313192.0 34.66999816894531325.0 39.22000122070312605.0 38.15999984741213075.0 35.40999984741212274.0 38.04000091552732804.0 39.61999893188483625.0 39.50999832153323004.0 39.75999832153323428.0 38.6899986267093767.0 39.49000167846683249.0 35.68000030517581801.0 37.84000015258792719.0 39.8100013732913727.0 35.27000045776371500.0 36.9399986267092297.0 38.90000152587893546.0 39.04000091552732989.0 39.65000152587893734.0 37.90000152587893591.0 37.43000030517582188.0 39.61000061035163379.0 37.33000183105472802.0 37.83000183105473590.0 37.66999816894532446.0 39.65000152587893105.0 39.20999908447272974.0 38.99000167846682982.0 38.50999832153323323.0 37.41999816894532360.0 32.8100013732911618.0 39.84999847412113664.0 38.99000167846683197.0 39.84999847412113003.0 39.90999984741213096.0 37.45999908447272938.0 37.49000167846683558.0 37.13000106811522622.0 37.54999923706052482.0 39.91999816894533723.0 38.65999984741213505.0 39.54000091552734205.0 38.02000045776373554.0 38.25999832153322699.0 37.04999923706052991.0 38.4399986267092831.0 37.33000183105472590.0 37.45999908447272879.0 39.09000015258793269.0 39.20000076293953254.0 38.54999923706052729.0 38.27000045776373078.0 39.53647.0 37.56999969482423099.0 39.11999893188483041.0 34.63999938964843009.0 39.52000045776373943.0 39.04999923706052913.0 39.70000076293952768.0 39.4399986267093341.0 39.97999954223633138.0 36.81999969482422545.0 38.34000015258793385.0 38.99000167846682951.0 39.41999816894532837.0 39.84999847412113079.0 34.13999938964842328.0 38.9399986267094122.0 32.63999938964841741.0 37.77999877929693571.0 38.88000106811523134.0 39.13999938964843109.0 36.15999984741213188.0 35.61999893188482505.0 38.253296.0 39.79999923706053518.0 39.8100013732914340.0 38.91999816894533448.0 39.66999816894533005.0 33.66999816894531880.0 36.45000076293952698.0 38.36000061035163561.0 39.84000015258793184.0 38.0600013732912252.0 39.02000045776372539.0 32.47000122070311402.0 39.77000045776373051.0 38.40999984741212257.0 36.40999984741213606.0 39.75999832153322127.0 39.93000030517582609.0 35.72999954223632545.0 37.97000122070312704.0 37.88999938964843260.0 38.59999847412113575.0 39.70999908447273582.0 37.74000167846681791.0 37.86000061035163001.0 38.58000183105473501.0 38.33000183105474057.0 37.38999938964842762.0 34.70000076293952751.0 37.09999847412112740.0 37.16999816894533007.0 38.58000183105472338.0 38.6899986267093360.0 38.59999847412113471.0 39.34999847412113292.0 39.75999832153322922.0 39.52000045776372995.0 37.58000183105473461.0 39.88000106811522579.0 37.74000167846683676.0 39.59999847412113233.0 37.65000152587892764.0 37.88000106811523552.0 36.91999816894532935.0 37.40000152587893545.0 39.753727.0 38.63000106811522926.0 39.45000076293953261.0 39.63999938964842610.0 39.86000061035163467.0 37.84999847412111546.0 39.83000183105474092.0 38.74000167846683932.0 36.27000045776372487.0 36.54000091552733198.0 37.47000122070313605.0 39.11000061035162894.0 38.25999832153322911.0 39.09999847412113332.0 37.08000183105472830.0 39.49000167846683226.0 38.09000015258792796.0 39.00999832153323784.0 39.84999847412113576.0 39.97000122070313942.0 38.18000030517583259.0 39.86000061035163430.0 34.86999893188482671.0 38.91999816894533064.0 37.33000183105472893.0 38.93000030517584071.0 39.00999832153324141.0 38.13999938964843451.0 38.58000183105473341.0 38.36999893188482215.0 38.68000030517584512.0 38.27000045776373571.0 39.04000091552733190.0 34.66999816894532597.0 34.59000015258792696.0 37.74000167846683392.0 37.16999816894533189.0 39.56999969482423354.0 38.27000045776372929.0 39.61999893188482921.0 38.20999908447273296.0 39.95000076293953303.0 36.34999847412112797.0 38.90000152587892887.0 39.58000183105473465.0 38.63999938964843774.0 38.4399986267092148.0 39.1899986267093305.0 35.70000076293952581.0 37.4399986267093184.0 37.86999893188483503.0 38.79999923706053007.0 39.34999847412113279.0 39.11999893188483566.0 39.47000122070313509.0 36.40000152587892391.0 38.50999832153322887.0 39.18000030517583942.0 39.70999908447274022.0 39.38000106811523798.0 39.54999923706053585.0 38.72000122070313306.0 32.79999923706051203.0 39.27000045776372894.0 39.45000076293953283.0 38.99000167846683804.0 39.34999847412113351.0 38.95999908447273035.0 39.22999954223633662.0 38.97000122070312724.0 39.33000183105473405.0 39.79999923706053751.0 38.15000152587892620.0 38.52000045776372974.0 0 1000 2000 3000 4000 5000 0 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 4200 4400 4600 4800 5000 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 1220 1240 1260 1280 1300 1320 1340 1360 1380 1400 1420 1440 1460 1480 1500 1520 1540 1560 1580 1600 1620 1640 1660 1680 1700 1720 1740 1760 1780 1800 1820 1840 1860 1880 1900 1920 1940 1960 1980 2000 2020 2040 2060 2080 2100 2120 2140 2160 2180 2200 2220 2240 2260 2280 2300 2320 2340 2360 2380 2400 2420 2440 2460 2480 2500 2520 2540 2560 2580 2600 2620 2640 2660 2680 2700 2720 2740 2760 2780 2800 2820 2840 2860 2880 2900 2920 2940 2960 2980 3000 3020 3040 3060 3080 3100 3120 3140 3160 3180 3200 3220 3240 3260 3280 3300 3320 3340 3360 3380 3400 3420 3440 3460 3480 3500 3520 3540 3560 3580 3600 3620 3640 3660 3680 3700 3720 3740 3760 3780 3800 3820 3840 3860 3880 3900 3920 3940 3960 3980 4000 4020 4040 4060 4080 4100 4120 4140 4160 4180 4200 4220 4240 4260 4280 4300 4320 4340 4360 4380 4400 4420 4440 4460 4480 4500 4520 4540 4560 4580 4600 4620 4640 4660 4680 4700 4720 4740 4760 4780 4800 4820 4840 4860 4880 4900 4920 4940 4960 4980 5000 0 5000 Birth weight (g)
Figure 10: Effect of number of gestational weeks on birth weights of the babies, adjusted by sex and hypertension.
Interpretation

Babies born from mothers with a hystory of hypertension, have on average, a lower birth weight and this is independent of their sex. For the group of babies whose mothers do not have a history of hypertension, girls have on average, a lower birth weight than boys. In all cases, as the number of gestational weeks increase, the birth weight also increases.

coef_plot(
    model_2,
    [
        "Gestational weeks",
        "Maternal \n hypertension",
        "Sex \n Female - Male"
    ]
)
Coefficients -200 -100 0 100 200 300 -200 -180 -160 -140 -120 -100 -80 -60 -40 -20 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 -200 -198 -196 -194 -192 -190 -188 -186 -184 -182 -180 -178 -176 -174 -172 -170 -168 -166 -164 -162 -160 -158 -156 -154 -152 -150 -148 -146 -144 -142 -140 -138 -136 -134 -132 -130 -128 -126 -124 -122 -120 -118 -116 -114 -112 -110 -108 -106 -104 -102 -100 -98 -96 -94 -92 -90 -88 -86 -84 -82 -80 -78 -76 -74 -72 -70 -68 -66 -64 -62 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 172 174 176 178 180 182 184 186 188 190 192 194 196 198 200 202 204 206 208 210 212 214 216 218 220 222 224 226 228 230 232 234 236 238 240 242 244 246 248 250 252 254 256 258 260 262 264 266 268 270 272 274 276 278 280 282 284 286 288 290 292 294 296 298 300 -300 0 300 -98.382172893683163 -80.664263479736382 191.004882373124251 h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? Gestational weeks Maternal hypertension Sex Female - Male Predictors
Figure 11: Coefficient plot for model predicting birth weight in babies.

8 Performance

8.1 Full data set

r2(model_2) |> r3
0.537
adjr2(model_2) |> r3
0.534
mape(bw_perf) |> r3
0.0
rmse(bw_perf) |> r3
435.164

8.2 Test data set

= MLJ.predict(mach, rows=test)
= predict_mode(mach, rows=test);
cross_entropy(ŷ, y2[test]) |> mean |> r3
7.466
coef_det(ȳ, y2[test]) |> r3
0.403